This is why I stick the ampersand ('&') to the end of the type name, like this:
int& a reference to an integer const string& a reference to a non-modifiable string ostream& a reference to an output stream
Hence, when you have ostream& operator << ( ostream& outs, const foo& f ), the thing returned from the function is a reference to an output stream. (Unless you are doing something tricky, it ought to be the same as the argument.) Notice also how the second argument is const.
1 2 3 4 5 6 7 8 9 10 11
struct point
{
int x, y;
point( int x = 0, int y = 0 ): x( x ), y( y ) { }
};
ostream& operator << ( ostream& outs, const point& p )
{
outs << "(" << p.x << ", " << p.y << ")";
return outs;
}