Question: What is the meaning of operator() in C++? I see that is often used for "functors," or function objects such as comparators. But then how are such functions called? Is it useful in other situations? And how many parameters can I declare for such an operator? E.g., is the following acceptable?

```
bool operator() (Foo f, Baz b, Quz q, Oik o) {...}

```

Answer: 
One point which I didn't see mentioned, was that although in syntax its invocation looks very similar to that of a regular non-member (dare I say, C-style) function. One difference is that since a functor/function-object is an instance of a class/struct, it can have an associated state.

For non-member functions this could usually mean, either static locals(often times not the best or most useful way to maintain state) or globals(often undesirable). Whereas functors/function objects tie in nicely with C++'s notions on encapsulation where in the state/data is closely tied to the functions that operate on it.

An instructive example of this is:

```
//Declaration
struct instructive_example
{
  instructive_example()
: _invocation_count(0) {};

  uint get_invocation_count() const
  { return _invocation_count; }

  void operator()()
  {
    //Do something

    //And/or operate on the state associated with this function object
    //In this case it is a simple increment of _invocation_count
    ++_invocation_count;
  }
private:
  uint _invocation_count;
};

//Instantiation & invocation:
instructive_example eg;

eg();

```
Like any overloaded operator, `operator()` is a strange-looking name of a function. It must be a member function of a class or struct, but there are no restrictions on its arguments other than the usual rules for all functions.

To evaluate the expression `x(`*args*`)` when the type of `x` is a class type, C++ will attempt to call `x.operator()(`*args*`)`, where *args* can be the empty string or any number of function arguments.