Advertisement
Alysik

Untitled

Nov 26th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.00 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class  Ship {
  5. protected:
  6.     string name;
  7.     int passanger;
  8. public:
  9.     virtual void input() = 0;
  10.     virtual void output() = 0;
  11. };
  12.  
  13. class Rocket_ship : public Ship {
  14.     string usingFor;
  15.     int year;
  16. public:
  17.     void input() {
  18.         cout << "Using for: " << endl;
  19.         cin >> usingFor;
  20.         cout << "Year of birth" << endl;
  21.         cin >> year;
  22.     }
  23.     void output() {
  24.         cout << "Using for " << usingFor << ". Year of birth " << year << endl ;
  25.     }
  26. };
  27.  
  28. class Passenger_ship : public Ship {
  29.     int amountOfPassanger;
  30.     int amountOfPersonal;
  31. public:
  32.     void input() {
  33.         cout << "Amount of passanger: " << endl;
  34.         cin >> amountOfPassanger;
  35.         cout << "Amount of personal: " << endl;
  36.         cin >> amountOfPersonal;
  37.     }
  38.     void output() {
  39.         cout << "Amount of personal " << amountOfPersonal << ". Amount of passanger " << amountOfPassanger << endl;
  40.     }
  41. };
  42.  
  43. int main()
  44. {
  45.     Ship* p = new Rocket_ship();
  46.     p->input();
  47.     p->output();
  48.     p = new Passenger_ship();
  49.     p->input();
  50.     p->output();
  51.     return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement