#include <iostream>
using namespace std;

/*

// First attempt:

template <class T> struct tmax {
   T operator()(T a, T b) { 
       return (a > b) ? a : b; 
   }
};

*/

struct tmax {
    template <class T> T operator()(T a, T b) { 
        return (a > b) ? a : b; 
    }
};

int main () {
    // Using the first attempt:
    //
    // tmax<int> max;
    //   max is now a function that obtains the maximum of two ints.
    //   We can use it as a function (shown below) and we can also
    //   pass it as argument to other functions (not shown here).
    //
    // cout << max(1, 2) << endl;  
    //
    // If we want to compare, say, strings, we need another
    // declaration (like the define_max template)

    // Just one declaration will do in the new and improved version:
    tmax max;

    cout << max(1, 2) << endl;                            // on int
    cout << max(string("alpha"), string("beta")) << endl; // on string
    cout << max(1.5, 6.3) << endl;                        // on float
    // cout << max (1.5, 6) << endl;                      // not going to work (why?)
}

