#include #include using namespace std; template const T & findMax(const vector & a, Comparator isLessThan) { int maxIndex = 0; for (int i = 1; i < a.size(); i++) { if (isLessThan( a[maxIndex], a[i] )) { maxIndex = i; } } return a[maxIndex]; } class LessThanByLength { public: bool operator() ( const string & lhs, const string & rhs) const { return lhs.size() < rhs.size(); } }; int main() { vector a; a.push_back("abc"); a.push_back("aceg"); a.push_back("xz"); cout << findMax(a, LessThanByLength() ) << endl; return 0; }