Using C++, implement the programming challenges from #12:
Implement:
1. Must overload the operator << to output each type of Ship.
2. Must overload the operator >> to enter the information for a CruiseShip.
3. Must overload the operator + to add more passenger capacity to a CruiseShip, e.g. cruiseship + n;
// increase the passenger capacity by an int n
4. Must overload the operator ++, both prefix and postfix form, to increment capacity to a CruiseShip, e.g. cruiseship++;
// increment the passenger capacity by 1
5. Each class must be implemented using the definition file (.h) and implementation file (.cpp).
Ship.h/Ship.cpp, CruiseShip.h/CruiseShip.cpp, and CargoShip.h/CargoShip.cpp
6. ShipTest.cpp is the main program.
Required I/O:
F. Last's Ship
12. Ship, Cruise Ship, and Cargo Ship Classes Design a ship class that has the following members:
A member variable for the name of the ship (a string) A member variable for the year that the ship was built (a string) A constructor and appropriate accessors and mutators A virtual print function that displays the ship's name and the year it was built.
Design a Cruise Ship 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 (an int) A constructor and appropriate accessors and mutators A print function that overrides the print function in the base class. The Cruise Ship class's print function should display only the ship's name and the maximum number of passengers.
Design a Cargo Ship class that is derived from the ship class. The Cargo Ship class should have the following members: A member variable for the cargo capacity in tonnage (an int) A constructor and appropriate accessors and mutators. A print function that overrides the print function in the base class. The Cargo Ship class's print function should display only the ship's name and the ship's cargo capacity.
Demonstrate the classes in a program that has an array of ship pointers. The array elements should be initialized with the addresses of dynamically allocated ship, Cruise Ship, and Cargo Ship objects. (See Program 15-14, lines 17 through 22, for an example of how to do this.) The program should then step through the array, calling each object's print function.