14.9 FILES AND STREAM CLASSES

C++ practices what it preaches. Since it advocates inheritance, it supports nice hierarchy of classes for supporting input output operations using files.

Files are treated like streams during program execution. A stream is a general name given to a flow of data. Each stream has a source and a destination. For output stream, the source is always memory variable and the destination is the file in which the data is to be written. For input stream, it is the reverse. Each stream is associated with a particular class which contains member functions and definitions for dealing with the particular kind of data flow. For example, ifstream class is associated with disk files used as input. Thus, each file in C++ program is ...

Get Object Oriented Programming with C++, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.