Streams


The stream library allows input/output operations on user-defined types (objects) using the same methods as for the built-in types.
The responsibility of providing a meaningful output implementation for the objects rests with the class designer not the user. cf. FORTRAN/C where every user has to do the work of converting the internal representation of a data type into an output string.
Streams are an alternative to the conventional C library functions in stdio.h.
Two overloaded stream operators are defined for output (<<) and input (>>).
Three streams (cout, cin and cerr) for normal output, input and error output respectively are opened automatically when a C++ program runs.
Manipulators are used to modify the way the i/o operations are done (e.g. precision, width etc.) and perform other special operations on a stream (flush etc.).