In C++ a functor is the name of a special kind of operator overloading. Defining a functor for a class allows you to treat an object as if it were a function. This can be confusing, so is rarely seen. An example would be:
class CSquare
{
public:
CSquare(){}
int operator()( int i )
{ return( i * i ); }
};
Then, using the above class definition, you could write something like the following:
int main()
{
CSquare square;
int s = square( 5 );
}
One possible use for functors is for multiple subscript arrays (i.e. matrices). Since overloading the bracket operator only allows a single parameter inside the brackets, you could instead define a functor that taks multiple subscripts.