File Stream Classes in C++

The I/O system of C++ contains a set of classes that define the file-handling methods. These include ifstream, ofstream and fstream. These classes are derived from StreamBase and the corresponding stream class in the figure: These classes are designed to manage the disk files that are declared in stream and therefore, we must include this file in any program that uses files.

File Stream Classes:

filebuf: Its purpose is to set the file buffers to read and write. Openprot constant used in the open() of the file stream classes. It also contain close() and open() as members.

fstreambase: It provides operations common to the file streams. It serves as a base for fstream, ifstream and ofstream classes. It also contain open() and close() functions.

ifstream: It provides input operations. It contains open() with default input mode. Inherits the functions get(), getline(), read(), seekg() and tellg() functions from istrem

ofstream: It provides output operations. It contains open() with default output mode. Inherits put(), seekp(), tellp() and write() functions from ostream.

fstream: It provides support for simultaneous input and output operations. inherits all the functions from istream and ostream classes through iostream.