Which among the following is mandatory condition for operators overloading?

Pham Quỳnh

New member
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 operands
 
Answer: a
Explanation: 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.
 

Tìm kiếm

Back
Top