+ 5
A stream is a name given to a flow of data at the lowest level. At the lowest level, data is just the binary data without any notion of data type. Different streams are used to represent the different kinds of data flow such as whether data is flowing into the memory or out of the memory. Each stream is associated with a particular class, that contains the member functions and definitions for dealing with that particular kind of data flow. For instance, the ifstream class represents the input disk files. The stream that supplies data to the program is known as the input stream. It reads the data from the file and hands it over to the program. The stream that receives data from the program is known as output stream. It writes the received data to the file. The file I/O system of C++ contains a set of classes that define the file handling methods. These classes, designed to manage the disk files, are declared in the header file named fstream.h. Therefore, we must include this file in a program that works with files. The classes defined inside the header file, fstream.h, derive from the classes under the header file iostream.h, the header file that manages console I/O operations. Therefore, if you include the header file fstream.h in your file handling programs, you need not to include iostream.h header file as classes of fstream.h inherit from iostream.h only.
6th Nov 2017, 1:00 PM
Harsh
Harsh - avatar