lab8_2.cpp

来自「c++模板小实验」· C++ 代码 · 共 51 行

CPP
51 行
字号
#include <iostream.h>
class vehicle
{
public:
	 void run(){cout<<"call vehicle's run"<<endl;}
     void stop(){cout<<"call vehicle's stop"<<endl;}
};

class bicycle:virtual public vehicle
{
	public:
	void run(){cout<<"call bicycle's run"<<endl;}
	void stop(){cout<<"call vehicle's  stop"<<endl;}
};



class motorcar:virtual public vehicle
{	
public:
	void run(){cout<<"call motorcar's run"<<endl;}
	void stop(){cout<<"call motorcar's  stop"<<endl;}
};



class motorcycle:public bicycle,public motorcar
{
public:
	void run(){cout<<"call motorcycle's run"<<endl;}
	void stop(){cout<<"call motorcycle's  stop"<<endl;}
};


void f(vehicle   *str)
{ 
	str->run();
	str->stop();
	return;
}
void main()
{
	vehicle a;
	bicycle b;
    b. run();
	b.stop();
    a.run();
    a.stop();
}
	

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?