1.

What is the syntax to overload an operator?(a) className::operator(parameters)(b) className:operator(parameters)(c) className.operator(paramteres)(d) className->operator(parameters)I had been asked this question in an online interview.I'd like to ask this question from Member Operator Function in division Member Functions & its Types of Object Oriented Programming

Answer»

Correct answer is (a) CLASSNAME::operator(parameters)

To explain I would say: The CLASS name is followed by the scope resolution operator. This is DONE to specify the class to which the FUNCTION should belong to. Then the KEYWORD operator should be used in order to indicate the operator that is to be overloaded. Then come the parameters list to specify other operands.



Discussion

No Comment Found

Related InterviewSolutions