Having rid yourself of display_capacity
, you might like to take the
next natural step: to rid yourself of display_short_name
as well.
Then, you could construct a for
loop in which all the displaying is
done explicitly:
for (n = 0; n < car_count; ++n) { // Display short name and capacity and terminate the line: cout << train[n] -> short_name ( ) << " " << train[n] -> capacity ( ) << endl; }
To define short_name
, using display_short_name
as a model, you
need to know what the return type should be:
// Definition in railroad_car virtual what type here? short_name ( ) {return "rrc";} // Definition in box_car virtual what type here? short_name ( ) {return "box";} ...