Home Segments Index Top Previous Next

240: Mainline

Sometimes, more than one member function with a particular name may show up in a subclass–superclass chain. Suppose, for example, that you must account for the tendency of railroads to pile material above the rims of gondola cars. Specifically, you must implement a volume member function for that kind of car, which is different from the volume member function defined in the box class:

*-------------------* 
| box               | 
|  volume function  | 
|  height           | 
|  width            | 
|  length           | 
*-------------------* 
          ^  ^ 
          |  | 
          |  *--------------------* 
          |                       | 
          |                       | 
*-------------------*   *-------------------* 
| box_car           |   | gondola_car       | 
|                   |   |  volume function  | 
*-------------------*   *-------------------*