1.

Which of the following is correct about Functors?(a) Functors should not be declared outside the main function(b) Overloaded operator () function is not a member of the class(c) Functors should be declared global(d) Functors have a stateI have been asked this question in unit test.This key question is from Functors in section Algorithms, Objects & Iterators in C++ of C++

Answer»

The correct choice is (d) Functors have a state

The EXPLANATION is: Functors are objects of a class which ALSO have other members and MEMBER functions which can be used to save states of that functors hence functors have a state. Functors can be declared anywhere in a PROGRAM.



Discussion

No Comment Found

Related InterviewSolutions