- 19
- 0
- 约6.79千字
- 约 18页
- 2020-10-11 发布于天津
- 举报
PAGE
PAGE # / 19
9.假定车可分为货车和客车,客车又可分为轿车、面包车和公共汽车。请设 计相应的类层次结构。
说明:可以把轿车、面包车和公共汽车定义为客车类的对象
参考程序:
#includeiostream
using namespace std;
class vehicle
{
public:// 定义基类 vehicle
// 公有函数成员
vehicle(int in_wheels,float in_weight); // 给数据成员初始化
intget_wheels();// 获取车轮数
float get_weight();// 获取汽车重量
void setWeels(int wls);
void setWeight(float wt);
void display(){
cout 车轮数: wheels
汽车重量: weightendl;
}
private:// 私有数据成员
int wheels;// 车轮数
float weight;// 表示汽车承重
};
vehicle::vehicle(int in_wheels,float in_weight){ }
float vehicle::get_weight(){
}
int vehicle::get_wheels(){ return wheels;
}
void vehicle::s
您可能关注的文档
最近下载
- 2026 年人教版四年级数学上册估算应用题专项练习.docx
- 《光纤色散》课件.ppt VIP
- 2026年全国高压电工证理论考试题库含答案.docx VIP
- 高血压的诊治课件.ppt VIP
- 2025湘艺版音乐八年级上册 《我们的生活充满阳光》教案教学设计.docx
- 第七章 城市综合交通规划.pptx VIP
- CSC-150数字式母线保护装置(国网六统一版本)说明书.pdf VIP
- 2025网课智慧树知道《马克思主义政治经济学(山东联盟).docx》章节测试答案.pdf VIP
- 施工项目部职业危害防治责任制度.docx
- 2018-2020年湖南师范大学《903地理信息系统概论》历年考研真题汇总.pdf VIP
原创力文档

文档评论(0)