Namespaces in C++
Legacy versus Modern C++ I/O
There are currently two versions of the C++ object-oriented I/O library in use: the older one that is based upon the original specifications for C++ and the newer one defined by Standard C++. The old I/O library is supported by the header file <iostream.h>.
The new I/O library is supported by the header <iostream>.
For the most part the two libraries appear the same to the programmer. This is because the new I/O library is, in essence, simply an updated and improved version of the old one.
In fact, the vast majority of differences between the two occur beneath the surface, in the way that the libraries are implemented, not in how they are used. From the programmer's perspective, there are two main differences between the old and new C++ I/O
libraries. First, the new I/O library contains a few additional features and defines some new data types. Thus, the new I/O library is essentially a superset of the old one. Nearly all programs originally written for the old library
will compile without substantive changes when the new library is used. Second, the old-style I/O library was in the global namespace.
The new-style library is in the std namespace. (Recall that the std namespace is used by all of the Standard C++ libraries.)
Since the old-style I/O library is now obsolete, this book describes only the new I/O library, but most of the information is applicable to the old I/O library as well
Like the C-based I/O system, the C++ I/O system operates through streams.
However, to summarize: A stream is a logical device that either produces or consumes information. A stream is linked to a physical device by the I/O system.
All streams behave in the same way even though the actual physical devices they are connected to may differ substantially. Because all streams behave the same, the same I/O functions can operate on virtually any type of physical device.
For example, you can use the same function that writes to a file to write to the printer or to the screen. The advantage to this approach is that you need learn only one I/O system.