I am trying to create two functions both named maximum (which overload each other) that compute the maximum of two arguments. The first should find maximum of two arguments of type double. The second should accept two arguments of type string (not C-string types) and should return the argument that comes alphanumerically second.
Intuitively I would think template in C++ but I try such and it failed. Any suggestions? trial code below:
template<class T>
T maximum(T first, T second){
if (first < second){
return second;}
else{
return first;}}
int main ()
{
int i = 1, j = 2, k;
k = maximum(i, j);
cout << k << endl;
char a[] = "llll" , b[] = "b", c[3];
cout << maximum(b ,a)<< endl;
system("PAUSE");
return 0;
}