Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Vehicle{
- private:
- float Maxspeed;
- float Weight;
- public:
- Vehicle(float m,float w):Maxspeed(m),Weight(w){}
- ~Vehicle(){}
- float GetMaxspeed(){return Maxspeed;}
- float GetWeight(){return Weight;}
- void Run();
- void Stop();
- };
- class Bicycle:virtual public Vehicle{
- private:
- float Height;
- public:
- Bicycle(float m,float w,float h):Height(h),Vehicle(m,w){}
- ~Bicycle(){}
- float GetHeight(){return Height;}
- };
- class Motorcar:virtual public Vehicle{
- private:
- int SeatNum;
- public:
- Motorcar(float m,float w,float n):SeatNum(n),Vehicle(m,w){}
- ~Motorcar(){}
- int GetSeatNum(){return SeatNum;}
- };
- class MotorBicycle:public Bicycle ,public Motorcar{
- public:
- MotorBicycle(float m,float w,float h,int n):Vehicle(m,w),Bicycle(m,w,h),Motorcar(m,w,n){}
- ~MotorBicycle(){}
- void Show()
- {
- cout<<"Maxspeed="<<GetMaxspeed()<<endl;
- cout<<"Weight="<<GetWeight()<<endl;
- cout<<"Height="<<GetHeight()<<endl;
- cout<<"SeatNum="<<GetSeatNum()<<endl;
- }
- };
- int main()
- {
- MotorBicycle motorBicycle(120,274.67,1.15,3);
- motorBicycle.Show();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement