Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Ship {
- protected:
- string name;
- int passanger;
- public:
- virtual void input() = 0;
- virtual void output() = 0;
- };
- class Rocket_ship : public Ship {
- string usingFor;
- int year;
- public:
- void input() {
- cout << "Using for: " << endl;
- cin >> usingFor;
- cout << "Year of birth" << endl;
- cin >> year;
- }
- void output() {
- cout << "Using for " << usingFor << ". Year of birth " << year << endl ;
- }
- };
- class Passenger_ship : public Ship {
- int amountOfPassanger;
- int amountOfPersonal;
- public:
- void input() {
- cout << "Amount of passanger: " << endl;
- cin >> amountOfPassanger;
- cout << "Amount of personal: " << endl;
- cin >> amountOfPersonal;
- }
- void output() {
- cout << "Amount of personal " << amountOfPersonal << ". Amount of passanger " << amountOfPassanger << endl;
- }
- };
- int main()
- {
- Ship* p = new Rocket_ship();
- p->input();
- p->output();
- p = new Passenger_ship();
- p->input();
- p->output();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement