1.

Which operator among the following must be overloaded using the friend function?(a) > operator only(c) Both > operators(d) It’s not mandatory to use friend function in any caseI have been asked this question by my college professor while I was bunking the class.I want to ask this question from Member Operator Function in division Member Functions & its Types of Object Oriented Programming

Answer»

Right option is (C) Both << and >> operators

The best I can explain: In some cases it is mandatory to use the friend functions for overloading the operators. Here both the << and >> operators must be OVERLOADED using friend function because the LEFT operand is object of some other class and the right operand is usually of some DIFFERENT type.



Discussion

No Comment Found

Related InterviewSolutions