previous | start | next

Overloading operator<<: 3

 ostream& operator<<(ostream& os, const Employee& e); 
     

The return type must be an ostream in order to write:

 cout << e << endl; 
     

because this will be equivalent to

  operator<<(cout, e) << endl;              
     

From this form it is clear that the type of the return value of operator<< must be acceptable as the left operand of <<.

That is, the return value must be of type ostream.



previous | start | next