Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    #include <string>
    #include <cstring>
    using namespace std;
    template <class type>
    type Maximum(const type value1, const type value2)
    {
    cout << "No Specialization";
    return value1 < value2 ? value2 : value1;
    }
    template <>
    const char *Maximum(const char *value1, const char *value2)
    {
    return (strcmp(value1, value2) < 0) ? value2 : value1;
    }
    int main()
    {
    string S1 = "class", S2 = "template";
    const char *value3 = "Interveiw";
    const char *value4 = "Mania";
    const char *q = Maximum(value3, value4);
    cout << q << endl;
    return 0;
    }
    1. template
    2. class
    3. Interveiw
    4. Mania
    5. None of these
Correct Option: D

In this program, We are computing the result in the specialized block of the program.



Your comments will be displayed only after manual approval.