#include #include using namespace std; //myClassTemplate3 // defiining template // using Type Template // compare with myStructNonType Template //where we used template template class Compare { public: T n1, n2; //Compare (T first, T second){n1=first; n2=second;} // Compare (int x1, int y1) { n1= x1,n2=y1; cout<<"\n Integer constructor :Handles Integers " ; } ; Compare (string x1, string y1) { n1= x1,n2=y1; cout<<"\n String Constructor : Handles string " ; } ; T higherValue (); //you can't call cout << "\n template defined " ; ~Compare(){ cout << "\n destructor worked"; }; private: T *ptr1; int n3; }; // defining template parameter type template T Compare::higherValue () { cout << "\n ----> template initialized " ; // T represents the method declared before T compare; // method or function that will compare to values cout << " \n value compared || " << n1 << " : " << n2 <<"\n Higher value is : "; compare = n1>n2? n1 : n2; return compare; } // int main () { cout << "\n--------main starts-----------"; int n11 = 100; Compare myobject1 (n11, 75); cout << myobject1.higherValue(); ComparemyString("Hi", "There"); cout << myString.higherValue(); Compare mydouble (12.25, 75.25); cout << mydouble.higherValue(); // Compare mymix ("Hello", 75.25); // cout << mydmix.higherValue(); cout << "\n--------main ends-----------"; return 0; }