Template Example 2 – C++ Language

#include <iostream>

using namespace std;
template<class X>
class test
{
private:
X a,b;
public:
test(X m, X n)
{
a=m;
b=n;
}
X display()
{
X temp;
temp= (a>b)?a:b;
cout<<“The result is: “<<temp<<endl;
}
};
int main()
{
test <float> obj(5,10.6);
obj.display();
return 0;
}