tailieunhanh - A Complete Guide to Programming in C++ part 63

A Complete Guide to Programming in C++ part 63. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | EXERCISES 599 Exercise I The multiply-derived class MotorHome needs to be fully implemented and tested. Define an enumeration type category that represents the categories Luxury First Class Middle Class and Economy . Develop a class called Home with two data members used to store the number of rooms and the size in square meters. Supply default values for your constructor definition to create a default constructor. In addition to access methods also define the method display which outputs the data members of an apartment. Define a class derived from the Car and Home classes called MotorHome which is used to represent motorhomes. Inheritance of public base classes is MotorHome class contains a new data member used to store one value of the category type. In addition to defining a constructor with default values also define appropriate access methods and a display method for output. Place your definitions of the Home and MotorHome classes in a separate header file which includes the existing header file . Write a main function that first fully initializes a MotorHome type object and then outputs the object. Then create a second instance of the MotorHome type without initial values and display the object on screen. Call all the set methods in the MotorHome class and its base classes to set your own values for the output the object once more. 600 CHAPTER 27 MULTIPLE INHERITANCE Class hierarchy for the multiply-derived class suv EXERCISES 601 Exercise 2 Now fully define the suv class for testing virtual base classes. Change the definition of the PassCar class in the header file to make Car a virtual base class of the PassCar class. Then define the Van class using the Car class as a virtual base new class should contain an additional data member used to represent the payload of the van in maximum of 750 kg applies to vans. The constructor should use default values to initialize the data members with defaults thus .

TỪ KHÓA LIÊN QUAN