iostream
If you need to use the same stream for input and output, you can use an object of the class iostream
, which is derived from both istream
and ostream
.
The constructors for iostream
behave just like the constructors for istream
.
iostream
constructor simply allocates a new ios
object, and initializes the input counter (the value reported by istream::gcount
) to 0
.
streambuf*
; if you supply this pointer, the constructor uses that streambuf
for input and output.
You can use the optional second argument tie (an ostream*
) to specify a related output stream as the initial value for ios::tie
.
As for ostream
and istream
, iostream
simply uses the ios
destructor. However, an iostream
is not deleted by its destructor.
You can use all the istream
, ostream
, and ios
methods with an iostream
object.