Which operator among the following must be overloaded using the friend function?

Bảo Vy

Member
Which operator among the following must be overloaded using the friend function?
A. << operator only
B. >> operator only
C. Both << and >> operators
D. It’s not mandatory to use friend function in any case
 
Answer: c
Explanation: 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.
 

Tìm kiếm

Back
Top