Home Segments Index Top Previous Next

496: Practice

You have seen, in this chapter, how you can have a default constructor call an argument-bearing constructor. You can also have an argument-bearing constructor call another argument-bearing constructor.

Suppose, for example, that all box cars have the same height and width—they vary only in length. Write a one-argument constructor for the box_car class that does all its work by calling the appropriate box class constructor.

Next, rewrite the default box_car constructor such that it makes use of the one-argument box_car constructor.