1.

For overloading “( )”, “[ ]” or “->” operators, a class __________(a) Must use static member functions(b) Must use non-static member functions(c) Must be non-static member and should not be friend of class(d) Must use static member function or a friend member functionThis question was addressed to me during an interview.My question is based upon Member Functions in section Class Members & Types of Object Oriented Programming

Answer»

The correct answer is (C) MUST be non-static member and should not be FRIEND of class

To explain I would SAY: For overloading those operators for a class, the class must use non-static member function so that doesn’t remain common to all the objects, and each OBJECT can use it independently. The friend functions is also restricted so as to keep the security of data.



Discussion

No Comment Found

Related InterviewSolutions