An iostream object is both a source and a destination for bytes. The two most important I/O stream classes, both derived from iostream, are fstream and strstream, as described below.
Note:
The fstream and strstream classes inherit the functionality of the istream and ostream classes described earlier.
The fstream Class
The fstream class supports disk file input/output. Construct an fstream object if you need an disk file that is to be both read from and written to in the same program.
The strstream Class
The strstream class supports input and output of in-memory strings. Construct an strstream object when you need to manipulate a string in memory using the iostream formatting facilities.