#include using namespace std; template bool MyLess(const T & a, const T & b) { return a < b; } template FunctionType Smallest(const FunctionType & a, const FunctionType & b) { if (a < b) { return a; } return b; } template void LessTest(T a, T b) { cout << "testing " << a << " < " << b << endl; if (MyLess(a,b) ) { cout << " it is true " << endl; } else { cout << " it is not true " << endl; } } class PersonT { public: PersonT(string n="Bob", int a=0): name(n), age(a){}; bool operator <(const PersonT & other)const { if (name == other.name) { return age < other.age; } return name < other.name; } friend ostream & operator << (ostream & s, const PersonT & p){ s << p.name << " " << p.age; return s; } private: string name; int age; }; int main() { string word1 = "hello"; string word2 = "world"; if ( MyLess(3,5)) { cout << " 3 < 5 " << endl; } else { cout << " 3 >= 5 " << endl; } int i{3}, j{5}; cout << endl; LessTest(i,j); LessTest(j,i); cout << endl; LessTest(word1, word2); LessTest(word2, word1); cout << endl; //LessTest(3, 3.14); LessTest(3, 3.14); LessTest(3, 3.14); cout << endl; PersonT a("Dan", 5); PersonT b; cout << endl; LessTest(a,b); LessTest(b,a); cout << endl; cout << "The smallest is " << Smallest(a, b) << endl; cout << "The smallest is " << Smallest(b, a) << endl; cout << "The smallest is " << Smallest(word1, word2) << endl; cout << "The smallest is " << Smallest(word2, word1) << endl; return 0; }