Question: Write a complete C + + program for Transport, Car and Motor classes based on the following specification: a . Design a Transport class that

Write a complete C++ program for Transport, Car and Motor classes based on the following
specification:
a. Design a Transport class that has the following members:
i. A member variable for the name of the transport (a string)
ii. A member variable for the year that the transport was built (a string)
iii. A constructor and appropriate accessors and mutators.
iv. A virtual print function that displays the transport's name and the year it was built.
b. Design a Car class that is derived from the Transport class. The Car class should have
the following members:
i. A member variable for the maximum number of passengers (an int)
ii. A constructor and appropriate accessors and mutators
iii. A print function that overrides the print function in the base class. The Car
class's print function should display only the car's name and the maximum number of
passengers.
c. Design a Motor class that is derived from the Transport class. The Motor class should
have the following members:
i. A member variable for the maximum number of passengers (an int)
ii. A constructor and appropriate accessors and mutators.
iii. A print function that overrides the print function in the base class. The Motor
class's print function should display only the motor's name and the maximum number
of passengers.
d. Write a main () method that has an array of Transport pointers. The array elements should be
initialized with the addresses of dynamically allocated Transport, Car, and Motor
objects. The program should then step through the array, calling each object's print function.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!