#include <iostream>
#include <cstring>
using std::cout;
using std::endl;
using std::cin;
using std::string;
//template function
template<typename T>
T func(T value1,T value2);
int main()
{
//Call func function for type the int, float, double, char
int val1,val2;
cout<<"Enter the value1 ";
cin>>val1;
cout<<"\nEnter the value2 ";
cin>>val2;
cout<<"\nlarge value is "<<func(val1,val2)<<endl;
//Call func function for type the string
string s1,s2;
cout<<"Enter the s1 ";
cin>>s1;
cout<<"\nEnter the s2 ";
cin>>s2;
cout<<"\nlarge value is "<<func(s1,s2)<<endl;
return 0;
}
template<typename T>
T func(T value1,T value2)
{
if(value1>value2)
return value1;
else
return value2;
}
Comments
Leave a comment