Advertisement
Tucancitto

MOŞTENIRE MULTIPLĂ

Jul 1st, 2021
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Vehicul
  5. {
  6. protected:
  7.     string firma;
  8.  
  9. public:
  10.     Vehicul(string firma = "") : firma(firma)
  11.     {
  12.         cout << "Acesta este un vehicul. \n";
  13.     }
  14. };
  15.  
  16. class Cu2Roti
  17. {
  18. protected:
  19.     float diametruRoata;
  20.  
  21. public:
  22.     Cu2Roti(float diametruRoata = 0) : diametruRoata(diametruRoata)
  23.     {
  24.         cout << "Acesta are 2 roti. \n";
  25.     }
  26. };
  27.  
  28. class Bicicleta : public Vehicul, public Cu2Roti
  29. {
  30. public:
  31.     Bicicleta(string firma = "", float diametruRoata = 0) :
  32.         Vehicul(firma), Cu2Roti(diametruRoata)
  33.     {
  34.         cout << "Firma : " << firma << endl;
  35.         cout << "Diametrul unei roti : " << diametruRoata << endl;
  36.     }
  37. };
  38.  
  39. int main()
  40. {
  41.     Bicicleta b;
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement