So
far in this book we’ve used the old reliable C standard I/O library, a
perfect example of a library that begs to be turned into a class.
In
fact, there’s much more you can do with the general I/O problem than just
take standard I/O and turn it into a class. Wouldn’t it be nice if you
could make all the usual “receptacles” – standard I/O, files
and even blocks of memory – look the same, so you need to remember only
one interface? That’s the idea behind iostreams. They’re much
easier, safer, and often more efficient than the assorted functions from the
Standard C stdio library.
Iostream
is usually the first class library that new C++ programmers learn to use. This
chapter explores the
use
of iostreams, so they can replace the C I/O functions through the rest of the
book. In future chapters, you’ll see how to set up your own classes so
they’re compatible with iostreams.