Thursday, 9 April 2015

I/O Stream Classes (C++)

During the development of C++ a new class-based input/output system was implemented.
This gave rise to the I/O stream classes, which are now available in a library of
their own, the so-called iostream library.
The diagram on the opposite page shows how a so-called class hierarchy develops due
to inheritance. The class ios is the base class of all other stream classes. It contains the
attributes and abilities common to all streams. Effectively, the ios class

  • manages the connection to the physical data stream that writes your program’s
    data to a file or outputs the data on screen.
  • contains the basic functions needed for formatting data. A number of flags that
    determine how character input is interpreted have been defined for this purpose.    
The istream and ostream classes derived from ios form a user-friendly interface
for stream manipulation. The istream class is used for reading streams and the
ostream class is used for writing to streams. The operator >> is defined in istream
and << is defined in ostream, for example.

The iostream class is derived by multiple inheritance from istream and ostream
and thus offers the functionality of both classes.

Further stream classes, a file management class, for example, are derived from the
classes mentioned above. This allows the developer to use the techniques described for file manipulation.

No comments:

Post a Comment