An Introduction to Numerical Methods in C++, Revised Edition

The C++ concept of derivation allows the programmer to develop a number of classes which, although distinct, share some common features. The common features may be incorporated in one or more base classes from which the other classes are derived. In this way much repetitive labour is saved, clarity and consistency are improved, and the possibility of error is diminished. We begin with some simple examples, and then reconsider the class string, this time as a derived class. We are led to a simplified discussion of the concept of input and output streams as derived classes. In particular, we show how to format streams, for purposes of tabulation, for example. Finally, we describe how to deal with input and output operations on external files.
Suppose we wish to define a class of objects representing points in the euclidean plane, and another class representing complex numbers. Each of these classes has a pair of real numbers as a common feature: the x and y coordinates in the first case, the real and imaginary parts in the second. Both classes may be derived from a single base class, the data members of which are a pair of real numbers. In both cases we shall wish to access the respective data members, and to deal with their input and output. It is natural, therefore, to include all these features in the base class.
We shall define the base class duple in the...