定义一个车类(Vehicle)基类,具有MaxSpeed,Weight成员变量,run(),stop(),构造函数,~~~~

[复制链接]
查看11 | 回复1 | 2013-11-27 08:19:21 | 显示全部楼层 |阅读模式
C++: 定义一个车类(Vehicle)基类,具有MaxSpeed,Weight成员变量,run(),stop(),构造函数等成员函数,由此派生出自行车(Bicycle)类,汽车(Motorcar)类。自行车类有高度(Height)属性,汽车类有座位(SeatNum)属性。

回复

使用道具 举报

千问 | 2013-11-27 08:19:21 | 显示全部楼层
#include class vehicle { protected:int MaxSpeed;int Weight; public:vehicle(int s,int w){MaxSpeed=s;Weight=w;}void SetMaxSpeed(int s){MaxSpeed=s;}void SetWeight(int w){Weight=w;}void Run(){cout<<"class vehicle is running!"<<endl;}void Stop(){cout<<"class vehicle has stopped!"<<endl;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行