Jim Langston wrote:
"Rolf Magnus" <ra******@t-online.de> wrote in message
news:e5*************@news.t-online.com... Jim Langston wrote: Sounds like you forgot to include the header for ostream.
#include <fstream>
That would be the header for (surprise!) fstream. The header for ostream
would be (surprise again!):
#include <ostream>
I stand corrected. I didn't look closely enough. I didn't remember what it
was so I just opened up a program that used it and saw <fstream> and thought
that was it since I don't have #include <ostream>. I must have that in a
header file somewhere. My bad.
Standard library implementation headers sometimes include other
standard headers in addition to those they are required to. This means
you get the include "for free" without being explicit about it, though
in this case "free" is a bad thing because you're relying on a
side-effect (which may change) rather than explicitly stating what you
want. Though for all I know, <fstream> always includes <ostream> --
not that that means you should use <fstream> instead, mind you.
Also, note that std::cout isn't defined in <ostream>; it's in
<iostream>.
Also, check out <iosfwd> sometime -- it doesn't pertain here, but it's
good to know about and kind of an interesting anomaly.
Luke