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.
A stream
acts like a source or destination. The source stream that provides data to the
program is called the input stream and the destination stream that receive
output from the program is called the output stream.
C++
contains cin and cout predefined streams that opens automatically when a
program begins its execution.cin represents the input stream connected to the
standard input device and cout represents the output stream connected to
standard output device.
C++ Stream Classes:
The C++
I/O system contains a hierarchy of classes that are used to define various
streams to deal with both the console and disk files. These classes are called
stream classes.
As shown in figure ios is the base class for istream(input stream) and ostream(output stream) which are base classes for iostream(input/output stream).
The class ios
is declared as the virtual base class so that only one copy of its members are
inherited by the iostream.
The class ios provides the basic support for formatted and unformatted input/output operations.The class istream provides the facilities for formatted and unformatted input while the class ostream(through inheritance) provides the facilities for formatted output.
The class iostream provides the facilities for
handling both input output streams. Three classes namely istream_withassign,
ostream_withassign and iostream_withassign add assignment operators to these
classes.
0 comments:
Post a Comment