A function object:
My attempt:
A Function Object, or Functor (the two terms are synonymous) is simply any object that can be called as if it is a function. An ordinary function is a function object, and so is a function pointer; more generally, so is an object of a class that defines operator().
Functors (Function Objects or Functionals) are simply put object + ().
It seems to me that option (3) is true, but I'm confused with option (1), is it true?
Can you explain it, please?
A function object is an instance of a class that defines the parenthesis operator as a member function. When a function object is used as a function, the parenthesis operator is invoked whenever the function is called. Consider the following class definition:
class biggerThanThree
{
public:
bool operator () (int val)
{ return val > 3; }
};
If we create an instance of class biggerThanThree, every time we reference this object using the function call syntax, the parenthesis operator member function is invoked.
Reference: