With volume
redefined to operate on box_car
objectsinstead
of on a height, width, and length combinationyou can rewrite the program
in Segment 151 as follows:
#includeclass box_car { public: double height, width, length; }; double volume (box_car b) { return b.height * b.width * b.length; } main ( ) { box_car x; x.height = 10.5; x.width = 9.5; x.length = 40.0; cout << "The volume of the box_car is " << volume (x) << endl; } --- Result --- The volume of the box_car is 3990