previous | start | next

Overloading operator <<: 1

What about writing an overloaded operator<< for the Employee class?

 cout << e1;   // same as cout.operator<<(e1) ???
     

Note: If the form were cout.operator<<(e1) then the overloaded operator<< would have to be written as a member of the class that cout belongs to - ostream!

Uh oh! The ostream class doesn't belong to us! That's why we have to write a non-member operator<<



previous | start | next