Home Segments Index Top Previous Next

238: Mainline

In the class hierarchy as developed so far, each class exhibits only a default constructor. When you create an object in such a hierarchy, all the default constructors in the object's class and superclasses are called automatically, and each has the opportunity to contribute to the values of the member variables associated with the new object. In particular, the default constructors in all the box_car class and all superclasses of the box_car class are called whenever a box_car object is created:

*--------------------* 
| container          | 
*--------------------* 
          ^ 
          | 
*--------------------*  *--------------------* 
| box                |  | railroad_car       | 
*--------------------*  *--------------------* 
          ^                       ^ 
          |                       | 
          |  *--------------------* 
          |  | 
       *---------* 
       | box_car | 
       *---------*