Advertisement
Ejejejejejjr

Множественное наследование

Dec 28th, 2020
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. class Car
  5. {
  6. public:
  7.     void Drive()
  8.     {
  9.         std::cout << "Я еду" << std::endl;
  10.     }
  11. };
  12.  
  13. class Airplane
  14. {
  15. public:
  16.     void Fly()
  17.     {
  18.         std::cout << "Я лечу" << std::endl;
  19.     }
  20. };
  21.  
  22. //множественное наследование
  23. class FlyingCar : public Car, public Airplane{};
  24.  
  25.  
  26. int main(int argc, char *argv[])
  27. {
  28.     setlocale(LC_ALL, "Rus");
  29.     srand(time(NULL));
  30.    
  31.     FlyingCar car;
  32.     car.Drive();
  33.     car.Fly();
  34.    
  35.    
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement