You are on page 1of 1

#include <iostream>

using namespace std;

template <class T>


class mypair {
T a,b;
public:
mypair (T first, T second)
{
a=first;
b=second;
}
T getmax ();
};

template <class T>


T mypair<T>::getmax ()
{
T retval;
if(a>b){
return a;
}
else {
return b;
}
}

int main () {
int a,b;
float c,d;
char e,f;
cout<<"Enter an integer values :"<<endl;
cin>>a>>b;
mypair <int> myobject1 (a,b);
cout<<"Maximum is :"<<myobject1.getmax()<<endl;
cout<<"Enter a float values :"<<endl;
cin>>c>>d;
mypair <float> myobject2 (c,d);
cout<<"Maximum is :"<<myobject2.getmax()<<endl;
cout<<"Enter a char :"<<endl;
cin>>e>>f;
mypair <char> myobject3 (e,f);
cout<<"Maximum is :"<<myobject3.getmax()<<endl;
return 0;
}

You might also like