Home Segments Index Top Previous Next

153: Mainline

Instead of handing three double-type arguments to box_car_volume, you can write a new function, volume, that takes just one argument, which you declare to be a box_car object. If you choose this approach, you need to change the body: instead of height, width, and length parameters, the body must refer to the box_car object's height, width, and length member variables:

double volume (box_car b) {return b.height * b.width * b.length;}