Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. class Vehicle{
  4. private:
  5. float Maxspeed;
  6. float Weight;
  7. public:
  8. Vehicle(float m,float w):Maxspeed(m),Weight(w){}
  9. ~Vehicle(){}
  10. float GetMaxspeed(){return Maxspeed;}
  11. float GetWeight(){return Weight;}
  12. void Run();
  13. void Stop();
  14. };
  15. class Bicycle:virtual public Vehicle{
  16. private:
  17. float Height;
  18. public:
  19. Bicycle(float m,float w,float h):Height(h),Vehicle(m,w){}
  20. ~Bicycle(){}
  21. float GetHeight(){return Height;}
  22. };
  23. class Motorcar:virtual public Vehicle{
  24. private:
  25. int SeatNum;
  26. public:
  27. Motorcar(float m,float w,float n):SeatNum(n),Vehicle(m,w){}
  28. ~Motorcar(){}
  29. int GetSeatNum(){return SeatNum;}
  30. };
  31. class MotorBicycle:public Bicycle ,public Motorcar{
  32. public:
  33. MotorBicycle(float m,float w,float h,int n):Vehicle(m,w),Bicycle(m,w,h),Motorcar(m,w,n){}
  34. ~MotorBicycle(){}
  35. void Show()
  36. {
  37. cout<<"Maxspeed="<<GetMaxspeed()<<endl;
  38. cout<<"Weight="<<GetWeight()<<endl;
  39. cout<<"Height="<<GetHeight()<<endl;
  40. cout<<"SeatNum="<<GetSeatNum()<<endl;
  41. }
  42. };
  43. int main()
  44. {
  45. MotorBicycle motorBicycle(120,274.67,1.15,3);
  46. motorBicycle.Show();
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement