bool operator()(Iterator it1, Iterator it2) const { return (*it1 < *it2); }
Can someone explain this function for me, thanks! is this means overload the operator ()? after overload this, how to use it ?
bool operator()(Iterator it1, Iterator it2) const { return (*it1 < *it2); }
Can someone explain this function for me, thanks! is this means overload the operator ()? after overload this, how to use it ?
here is an example of overloading parentheses
http://www.java2s.com/Code/Cpp/Overload/DemoOverload.htm
and another
http://www.learncpp.com/cpp-tutorial/99-overloading-the-parenthesis-operator/
It means something like if you have a class
called Compare
for example:
Compare cmp;
....
if(cmp(it1, it2))
{
std::cout << "First element is greater";
}
else
{
std::cout << "Second element is greater";
}
Your object becomes like a function
and it is called in C++
world Functor
.