#include #include #include using namespace std; bool isLessThan( const string & lhs, const string & rhs ) { return strcasecmp( lhs.c_str( ), rhs.c_str( ) ) < 0; } template const Object & findMax( const vector & arr, bool (*compar)(const Object&, const Object&)) { int maxIndex = 0; for( int i = 1; i < arr.size( ); ++i ) if( compar( arr[ maxIndex ], arr[ i ] ) ) maxIndex = i; return arr[ maxIndex ]; } int main( ) { vector arr = { "ZEBRA", "alligator", "crocodile" }; cout << findMax( arr, isLessThan) << endl; return 0; }