MARSHAL327

Untitled

Jan 10th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.27 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class horse {
  5.     int speed, age;
  6. public:
  7.     horse() {
  8.         speed = age = 0;
  9.     }
  10.  
  11.     horse(int _speed, int _age) {
  12.         speed = _speed;
  13.         age = _age;
  14.     }
  15.     ~horse() {
  16.         speed = age = 0;
  17.     }
  18.  
  19.     int horse_age() {
  20.         return age++;
  21.     }
  22.  
  23.     int run() {
  24.         return speed++;
  25.     }
  26.  
  27.     void horse_print() {
  28.         cout << speed << "  " << age << endl;
  29.     }
  30. };
  31.  
  32. class bird  {
  33.     int height_fly, eggs;
  34. public:
  35.     bird(){
  36.         height_fly = eggs = 0;
  37.     }
  38.  
  39.     bird(int _height_fly, int _eggs) {
  40.         height_fly = _height_fly;
  41.         eggs = _eggs;
  42.     }
  43.  
  44.     ~bird() {
  45.         height_fly = eggs = 0;
  46.     }
  47.  
  48.     int up() {
  49.         return height_fly++;
  50.     }
  51.  
  52.     int lay_eggs() {
  53.         return eggs++;
  54.     }
  55.  
  56.     void bird_print() {
  57.         cout << height_fly << "  " << eggs << endl;
  58.     }
  59. };
  60.  
  61. class pegas : public horse, public bird {
  62.     int s;
  63. public:
  64.     pegas() { s = 0; }
  65.     pegas(int _speed, int _age, int _height_fly, int _eggs, int _s) :horse(_speed, _age), bird(_height_fly, _eggs) {
  66.         s = _s;
  67.     }
  68.     void pegas_print() {
  69.         horse_print();
  70.         bird_print();
  71.     }
  72. };
  73.  
  74. int main() {
  75.     horse H;
  76.     bird B;
  77.     pegas P;
  78.  
  79.     H.horse_age();
  80.     H.horse_age();
  81.     H.horse_age();
  82.     H.horse_age();
  83.     H.run();
  84.  
  85.     B.up();
  86.     B.up();
  87.     B.lay_eggs();
  88.     B.lay_eggs();
  89.     B.lay_eggs();
  90.  
  91.     P.pegas_print();
  92.    
  93.     return 0;
  94. }
Add Comment
Please, Sign In to add comment