登录
首页 » 文档处理 » 定义一个车(vehicle)基类,有Run、Stop等成员函数,由此派生出自行车(bicycle)类、汽车(motorcar)类,从bicycle和motorc...

定义一个车(vehicle)基类,有Run、Stop等成员函数,由此派生出自行车(bicycle)类、汽车(motorcar)类,从bicycle和motorc...

于 2022-08-11 发布 文件大小:43.16 kB
0 48
下载积分: 2 下载次数: 1

代码说明:

定义一个车(vehicle)基类,有Run、Stop等成员函数,由此派生出自行车(bicycle)类、汽车(motorcar)类,从bicycle和motorcar派生出摩托车(motorcycle)类,它们都有Run、Stop等成员函数。在main()函数中定义vehicle、bicycle、motorcar、motorcycle的对象,调用其Run()、Stop()函数,观察其执行情况。再分别用vehicle类型的指针来调用这几个对象的成员函数,看看能否成功;把Run、Stop定义为虚函数,再试试看。-The definition of a car (vehicle) base class, with Run, Stop and other member functions, thus derived a bike (bicycle), automobiles (motorcar) class, derived from the bicycle and motorcar motorcycle (motorcycle) class, they all Run , Stop and other member functions. In the main () function is defined in the vehicle, bicycle, motorcar, motorcycle object, call its Run (), Stop () function is to observe its implementation. Each with a pointer with the vehicle type to call the member functions of these objects to see if successful the Run, Stop is defined as virtual functions, try again.

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 696518资源总数
  • 104225会员总数
  • 32今日下载