Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    template<typename type>
    class Test
    {
    public:
    virtual type Function(type num1)
    {
    return num1 * 2;
    }
    };
    int main()
    {
    Test<int> num1;
    cout << num1.Function(150) << endl;
    return 0;
    }
    1. 2
    2. 150
    3. Compilation Error
    4. 300
    5. Runtime Error
Correct Option: D

In this program, We are using class to pass the value and then we are manipulating it.



Your comments will be displayed only after manual approval.