Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hello can someone help me answer this with c++ on Xcode. Design a Ship class that has the following members: A member variable for the
Hello can someone help me answer this with c++ on Xcode.
Design a Ship class that has the following members: A member variable for the name of the ship A member variable for the year that the ship was built . A constructor and appropriate getter and setter functions (accessor/mutators) A virtual print function that displays the ship's name and the year it was built. Design a Cruiseship class that is derived from the ship class. The Cruise ship class should have the following members: A member variable for the maximum number of passengers A constructor and appropriate getter and setter functions A print function that overrides the print function in the base class. The cruiseship class' print function should display only the ship's name and the maximum number of passengers Design a Cargoship class that is derived from the ship class. The Cargoship class should have the following members: A member variable for the cargo capacity in tonnage A constructor and appropriate getter and setter functions A print function that overrides the print function in the base class. The Cargoshte class print function should display only the ship's name and the ship's cargo capacity. Write a program that has an array of Ship pointers. The array elements should be initialized with the addresses of dynamically allocated ship. Cruiseship, and Cargoship objects (use the new keyword with the constructor which returns a pointer to the new object). The program should then step through the array and call 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