Question
In this assignment a class hierarchy is created with three classes. The three classes are described below. Ship class (include Ship.h and Ship.cpp) Contains data
In this assignment a class hierarchy is created with three classes. The three classes are described below.
Ship class (include Ship.h and Ship.cpp) Contains data members for the following
String for name of the ship
Integer for the year the ship was built
Constructor with parameters
Accessors and mutators for the data members
A Virtual print function that displays the ships name and the year it was built
CruiseShip (include CuriseShip.h and CruiseShip.cpp) class that is derived from the Ship class.
Contains data members for the following
Integer for the maximum number of passengers
Constructor Accessor and mutator for the data member
A print function that overrides the print function in the base class.
This print function should display only the ships name and the maximum number of passengers.
CargoShip (include CargoShip.h and CargpShip.cpp) class that is derived from Ship class
. Contains data members for the following
Integer for the cargo capacity in tonnage
Constructor Accessor and mutator for the data member
A print function that overrides the print function in the base class.
This print function should display only the ships name and the cargo capacity.
Main should create an array of Ship pointers. The array should be able to hold six elements. The array elements should be initialized with the addresses of dynamically allocated Ship, CruiseShip, and CargoShip objects. The program should then have two methods that is passed the array of Ship pointers (the array), one method will iterate thru the array calling the print method. The other method will determine which ship is older. The array should have two instances of each of the classes.
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