views:

261

answers:

2

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 ?

+5  A: 

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.

AraK