When overloading the insertion operator (operator<<) in order to insert an object (say a shae) into an output stream (file or console), we had to implement it as a global function. why was this? Could someone show me an example prototype for this function for inserting a shape into an ostream object? How is this different than having this operator as a member of our class(like a shape)?
Asked
Active
Viewed 153 times
0
-
look under **Bitshift Operators (used for Stream I/O)** in the first answer. – NathanOliver Jan 22 '16 at 18:30
-
http://stackoverflow.com/a/34954015/434551 – R Sahu Jan 22 '16 at 19:02
-
This is already answered in [this answer](http://stackoverflow.com/questions/4421706/operator-overloading/4421729#4421729) to the operator overloading FAQ. – sbi Mar 23 '16 at 23:02