第十四周实验容1.docVIP

  • 20
  • 0
  • 约16.1万字
  • 约 30页
  • 2017-01-29 发布于河南
  • 举报
第十四周实验容1

第十四周实验内容:继承与派生1. 编程【问题描述】: 开发一个名为 Vehicle的类的层次体系。创建两个类Taxi和Truck,均以公有模式从类Vehicle中继承而来。Taxi类中应包含一个数据成员说明其是否载客。Truck类应包含一个数据成员说明其是否载货。添加必要的函数来控制和访问类的数据。编写一段测试程序,将Truck对象和Taxi对象打印到屏幕。【实例输出】【程序模板】共7个文件(Vehicle.h、Vehicle.cpp、Taxi.h、Taxi.cpp、Truck.h、Truck.cpp、driver.cpp)*************************************************************// vehicle.h#ifndef VEHICLE_H#define VEHICLE_H#include iostreamusing namespace std;class Vehicle{public: Vehicle( const int doors, const int cylinders, char *color, double initialFuel, const int transmission ); ~Vehicle(); void setColor ( char *color); void setFuelLevel(

文档评论(0)

1亿VIP精品文档

相关文档