Lecture 3 - Slide 19 : 27
Stream State
Streams in C++ have state associated that represents
error conditions
and
formatting details
The C++ Prog. Lang. (3. edition)
:
Page 616
The C++ Prog. Lang. (4. edition)
: Page 1080
A stream can be in one of the following states - via function predicates from
basis_ios
strm.good()
The previous IO operation succeeeded
strm.eof()
The user hits end-of-input (Ctrl-D)
strm.fail()
Unexpected failure - such as expecting a digit, getting a non-digit
strm.bad()
Serious problem - such as disk read error.
A stream can be used as a condition - in a boolean context
The value is
true
if the state of the stream is
good()
Illustration of implicit stream conversion to a boolean value - and stream states.