1.

Which among the following is mandatory condition for operators overloading?(a) Overloaded operator must be member function of the left operand(b) Overloaded operator must be member function of the right operand(c) Overloaded operator must be member function of either left or right operand(d) Overloaded operator must not be dependent on the operandsThe question was asked in an interview for job.The question is from Member Operator Function topic in section Member Functions & its Types of Object Oriented Programming

Answer»

The correct option is (a) Overloaded operator MUST be member FUNCTION of the left operand

To explain I would say: The operator to be overloaded must be made the member function of the operand on left side of EXPRESSIONS to be used. This allows the compiler to identify whether the overloading has to be used or not. This rule also reduces the ambiguity in CODE.



Discussion

No Comment Found

Related InterviewSolutions