These lecture notes are only an introduction to the topic of I/O streams. For example since C++ is an extension of C, all of the C I/O techniques work in C++. However, since the C I/O does not handle the I/O of class objects, the C techniques will not be discussed.
C++ handles I/O through I/O streams. A stream produces or consumes data. Each stream is linked to a physical device through an object of a class and manipulated by the methods of that class. The physical devices are treated the same and are considered "files". The "files" can be a keyboard, the CRT, a printer, RAM, an OS file etc. In C++ there are two kinds of files: Text and Binary.
The I/O streams are based on classes. Some objects handle 8-bit and others handle wide character data. Some of the I/O classes are in the header: iostream. This header contains the I/O classes: ios, streambuf and their derived classes: istream, ostream and iostream. These are 5 of the 18 I/O classes. Whenever a program begins, four I/O objects: cin, cout, cerr and clog are created. These objects handle the 8-bit character. The objects cin and cout are the standard buffered input and output objects respectively. The object cerr is standard buffered error output (i.e. immediate output) and clog is standard unbuffered error output (i.e. output when the buffer is full.)
In addition to the I/O objects and their operators discussed above, C++ also contains the objects: wcin, wcout, wcerr and wclog. These objects work with the wide characters like the Chinese and Japanese characters. Since these notes will only be using the 8-bit characters, these four wide character objects will not be discussed in these notes. However, since we live in a world wide economy, it would be a good idea if you experiment with these objects. Look at the graphic below to observe the interrelationships between the I/O classes.