Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename type>
    type Maximum(type num1, type num2)
    {
    return num1 > num2 ? num1:num2;
    }
    int main()
    {
    int Res;
    Res = Maximum(150, 250);
    cout << Res << endl;
    return 0;
    }
    1. 250
    2. 150
    3. Compilation Error
    4. Runtime Error
    5. None of these
Correct Option: A

In this program, We are returning the maximum value by using function template.



Your comments will be displayed only after manual approval.