-
What is the output of this program?
#include <iostream>
using namespace std;
template<typename type>
class Example
{
public:
Example()
{
};
~Example()
{
};
Example FunctionA(Example num1)
{
return num1;
}
Example FunctionB(Example num2)
{
return num2;
}
};
int main()
{
Test<int> num1;
Test<float> num2;
cout << num1.FunctionA(150) << endl;
cout << num2.FunctionB(2.125) << endl;
return 0;
}
-
- 150
- 2.125
- 2.125
150 - 150
2.125 - Compilation Error
Correct Option: D
In this program, We are passing the values and getting it back from template. And we are using the constructor and destructor for the function template.