+ 4

How to overload operator<< in cpp ?

How to overload operator<< function in cpp of a class for desired output ?

2nd Feb 2020, 8:05 AM
Terminal_Phantom
Terminal_Phantom - avatar
3 ответов
+ 1
I have an example in this: https://code.sololearn.com/cStdw0OPtPxG
2nd Feb 2020, 8:29 AM
John Wells
John Wells - avatar
+ 4
Does the operator<< really need to be a friend function or there is a way we can define it inside the class
2nd Feb 2020, 8:38 AM
Terminal_Phantom
Terminal_Phantom - avatar
0
I believe it must be a friend because cout will not call via a method invocation.
2nd Feb 2020, 8:40 AM
John Wells
John Wells - avatar