As explained in Chapter 14, there are two versions of C++’s iostream library: the old style defined by early versions of C++, and the modern approach as defined by the ANSI/ISO Standard for C++ (Standard C++). The old-style library was described in the preceding section. The Standard C++ iostream library is described here.
There are two fundamental differences between the old-style and the Standard C++ iostream libraries. First, the old-style library was defined in the global namespace. The Standard C++ iostream library is contained in the std namespace. Second, the old-style library uses C-like .h header files. The Standard C++ library uses C++ headers (which don’t use the .h).
To use the Standard C++ iostream library, include the header <iostream> in your program. After doing that, you will usually want to bring the library into your current namespace using a statement like this:
using namespace std;
After the using statement, both the old-style and modern libraries work in much the same way.
It is not necessary to use the using statement just described. Instead, you can include an explicit namespace qualifier each time you refer to a member of the I/O classes. For example, the following explicitly refers to cout:
std::cout << "This is a test";
Of course, if you will be making extensive use of the iostream library, then including the using statement makes things less tedious.