previous | start | next

## The Inheritance Hierarchy of Stream Classes

- The standard `cin` and `cout` objects belong to specialized system-dependent classes with nonstandard names.
- You can assume that `cin` belongs to a class that is derived from `istream` and `cout` belongs to a class derived from `ostream`.
- Take advantage of the inheritance relationships between the stream classes whenever you write functions with stream parameters.

  >     double rand_data(istream& in);

- You can now pass parameters of types derived from `istream`, such as a `ifstream` object or `cin`.

  >     max = read_data(infile);
  >     max = read_data(cin);

- Remember to pass the streams by reference to avoid slicing.

previous | start | next