⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lab8_2.cpp

📁 该程序包括了一个具体实例
💻 CPP
字号:
// lab8_2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "iostream.h"
class vehicle
{
public:
	virtual void Run() {cout<<"Construct a vehicle!"<<endl;}
	virtual void Stop() {cout<<"Destruct a vehicle!"<<endl;}
	
};
class bicycle:public vehicle
{
public:
	void Run() {cout<<"Construct a bicycle!"<<endl;}
	void Stop() {cout<<"Destruct a bicycle!"<<endl;}
};
class motorcar:public vehicle
{
public:
	void Run() {cout<<"Construct a motorcar!"<<endl;}
	void Stop() {cout<<"Destruct a motorcar!"<<endl;}
};
class motorcycle:public bicycle,public motorcar
{
public:
	void Run() {cout<<"Construct a motorcle!"<<endl;}
	void Stop() {cout<<"Destruct a motorcle!"<<endl;}
};
void fun(vehicle *p)
{
  p->Run();
  p->Stop();
}
void main()
{
   vehicle v,*p;
   bicycle b;
   motorcar m;
   motorcycle n;
   p=&v;
   fun(p);
   p=&b;
   fun(p);
   p=&m;
   fun(p);
   
}

⌨️ 快捷键说明

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