1

so I was studying how to define a Comparison function in C++ and I referred to this article. It introduces a way by doing something like:

struct cmp
{
    bool operator()(int a, int b)
    {
        return occurrences[a] < occurrences[b];
    }
};

I did some research on this operator() but didn't find too much information, so my question is: what exactly operator() is and why by doing so can successfully define a comparison function? What is the rationale behind this?

OD Street
  • 1,067
  • 3
  • 14
  • 21

0 Answers0