I saw this function operator() been used here and there. But I can't find much information about it on web. Can anyone please explain what it does, when to use it.
Thanks.
here is a example:
#include <iostream>
#include <algorithm>
using namespace std;
// using default comparison:
cout << "The smallest element is " << *min_element(myints,myints+7) << endl;
cout << "The largest element is " << *max_element(myints,myints+7) << endl;
// using function myfn as comp:
cout << "The smallest element is " << *min_element(myints,myints+7,myfn) << endl;
cout << "The largest element is " << *max_element(myints,myints+7,myfn) << endl;
// using object myobj as comp:
cout << "The smallest element is " << *min_element(myints,myints+7,myobj) << endl;
cout << "The largest element is " << *max_element(myints,myints+7,myobj) << endl;