Practic Mode : Paper-II & III On Topic : O-O Programming Concepts with C++

Que : 1 . A function object: (Dec-2004)

1. is an instance of a class for which operator () is a member function.
2. is an instance of a class for which operator --> is a member function.
3. is a pointer to any function
4. is a member function of a class
Please Select Ans Options .
Explanation

Option 3 is Correct Answer.
A function object is a pointer to any function. 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 + ().
This includes normal functions, pointers to functions, and class objects for which the () operator (function call operator) is overloaded, i.e., classes for which the function operator()is defined.
Function objects are another example of the power of generic programming and the concept of pure abstraction. We could say that anything that behaves like a function is a function. So, if we define an object that behaves as a function, it can be used as a function.