Late submissions not accepted Ship cruiseship and cargoship
Late submissions not accepted. Ship, cruiseship, and cargoship Classes. Design a ship class than 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 CruiseShip class that is derived from the ship class. The cruiseShip 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 cruiseShip class\'s print function should display only the ship\'s name and the maximum number of passengers. Design a cargoShip class that derived from the ship class. The CargoShip 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 cruiseShip class\'s print function should display only the ship\'s name and the ship\'s cargo capacity.
Solution
#include<conio.h>
#include<iostream.h>
class ship
{
int year;
char *name;
public:
ship();
{
cin>>name;
cin>>year;
}
void display()
{
cout<<\"Name of the ship-\"<<name<<endl;
cout<<\"Year-\"<<year<<endl;
}
};
void main()
{
ship s;
s.display();
getch();
}
