// Examine this file and you will find that it is the // implementation of the vehicle class. The initialize() method // assigns the values input as parameters to the wheels and weight // variables. We have methods to return the number of wheels and // the weight, and finally, we have one that does a trivial // calculation to return the loading on each wheel. We will have // a few examples of methods that do some significant processing // later, but at this point, we are more interested in learning // how to set up the interface to the classes, so the // implementations will be kept trivial. #include #include "vehicle.h" using namespace std; int main() { vehicle car, motorcycle, truck, sedan; car.initialize(4, 3000.0); motorcycle.initialize(2, 900.0); truck.initialize(18, 45000.0); sedan.initialize(4, 3000.0); cout << "The car has " << car.get_wheels() << " wheels.\n"; cout << "The truck has a loading of " << truck.wheel_loading() << " pounds per wheel.\n"; cout << "The motorcycle weighs " << motorcycle.get_weight() << " pounds.\n"; cout << "The sedan weighs " << sedan.get_weight() << " pounds, and has " << sedan.get_wheels() << " wheels.\n"; return 0; } // Result of execution // // The car has 4 wheels. // The truck has a loading of 2500 pounds per wheel. // The motorcycle weighs 900 pounds. // The sedan weighs 3000 pounds, and has 4 wheels.