Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started