#include #include #include using namespace std; template T Max(T a, T b) { return (a > b ? a : b); } char* Max(char* a, char* b) { return ((strcmp(a,b) > 0) ? a : b); } int main(void) { // Testing primitive types cout << Max(3,4) << endl; cout << Max(4.55,1.23) << endl; cout << Max('a','d') << endl; cout << Max('N',Max('H','U')) << endl; cout << Max('N',Max('H','U')) << endl; // cout << Max(static_cast(2),3) << endl; // ERROR cout << Max(static_cast(2),static_cast(3)) << endl << endl; // Testing strings string s1("Dog"); string s2("Cat"); string s3("Horse"); cout << Max(s1,s2) << endl; cout << Max(s2,s3) << endl << endl; // Testing char arrays char array1[16], array2[16], array3[16]; strcpy(array1,"dog"); strcpy(array2,"cat"); strcpy(array3,"horse"); cout << Max(array1,array2) << endl; cout << Max(array2,array3) << endl; cout << reinterpret_cast(array1) << endl; cout << reinterpret_cast(array2) << endl; cout << reinterpret_cast(array3) << endl; }