Home » C++ Programming » Templates » Question
  1. What is the output of this program?
    #include <iostream>
    using namespace std;
    template <class type>
    class Sample
    {
    public:
    Sample()
    {
    };
    ~Sample()
    {
    };
    type FunA(type num1)
    {
    return num1;
    }
    type FunB(type num2)
    {
    return num2;
    }
    };
    int main()
    {
    Sample<int> num1;
    Sample<double> num2;
    cout << num1.FunA(250) << " ";
    cout << num2.FunB(5.225);
    return 0;
    }
    1. 250
    2. 5.225
    3. 5.225 250
    4. 250 5.225
    5. None of these
Correct Option: D

In this program, We are passing the value and returning it from template.



Your comments will be displayed only after manual approval.