C++程序设计实验.pdfVIP

  • 3
  • 0
  • 约1.77千字
  • 约 2页
  • 2020-04-27 发布于安徽
  • 举报
实验内容 声明一个 Vehicle (车)基类,有 Run、Stop 等成员函数,由此派 生出 bicycle (自行车)类和 motorcar (汽车)类,从 bicycle 类和 motorcar 类派生出 motorcycle (摩托车)类,它们都有 Run、Stop 等成员函数。实现并测试这些类,注意虚基类和虚函数的使用。 实验程序代码 实验代码: #include iostream using namespace std; class Vehicle { public: virtual void Run() // 声明虚函数 Run {coutVehicle::Run()endl;} virtual void Stop() // 声明虚函数 Stop {coutVehicle::Stop()endl;} }; class bicycle: virtual public Vehicle //派生类 bicycle 定义 { public: void Run()

文档评论(0)

1亿VIP精品文档

相关文档