interesting ostream question

Started by
2 comments, last by jdhardy 18 years, 6 months ago
After reading this page about operator<< for ostreams, I noticed that there aren't any overloads for const references. So how then does an ostream handle code like this?:

writer << "some text\n";
writer << 1234;
Notice how 1234 is a const int, so how does that work? Just curious is all [wink]
Advertisement
Simple. The page you linked to is wrong. The insertion operator for an ostream takes an int argument not an int reference.
Of course I did suspect that the page was wrong, except I thought that it would probably use const references instead.

That makes much more sense, thanks
According to MSDN the primitives are passed by value, not reference.

This topic is closed to new replies.

Advertisement