/*
*   04737 c++ 自学考试2019版 第五章课后练习
*   程序设计题 1
*   需求:交通工具包含汽车,汽车又包含.....
*/#include<iostream>
#include<string>
using namespace std;//奥迪轿车
class AudiCar{protected:string seriesProducts;//产品系列public:AudiCar(string seriesProducts_):seriesProducts(seriesProducts_){}//构造函数 friend   ostream & operator<<(ostream &out,AudiCar &audi);
};//重载输出流
ostream & operator<<(ostream &out,AudiCar &audi){out<<"产品系列:"<< audi.seriesProducts<<endl;return out;
}//轿车类
class Car{protected:string carBrandName;//汽车品牌AudiCar audi;//奥迪汽车public:Car(string carBrandName_,string seriesProducts):carBrandName(carBrandName_),audi(seriesProducts){} //构造函数 friend    ostream & operator<<(ostream &out,Car &c); };//重载输出流
ostream & operator<<(ostream &out,Car &c){out<<"汽车品牌:"<< c.carBrandName<<endl;out<<c.audi;return out;
}//汽车类
class AutoMobile{protected:string AutoMobileCategory;//汽车类别Car car;//轿车 public:AutoMobile(string AutoMobileCategory_,string carBrandName,string seriesProducts):AutoMobileCategory(AutoMobileCategory_),car(carBrandName,seriesProducts){}//构造函数 friend ostream & operator<<(ostream &out,AutoMobile &a);
}; //重载输出流
ostream & operator<<(ostream &out,AutoMobile &a){out<<"汽车类别:"<< a.AutoMobileCategory<<endl;out<<a.car;return out;
}//交通工具类
class Vehicle{protected:string VehicleCategory;//交通工具类别AutoMobile am;//汽车 public:Vehicle(string VehicleCategory_,string AutoMobileCategory,string carBrandName,string seriesProducts):VehicleCategory(VehicleCategory_),//交通类别am(AutoMobileCategory,carBrandName,seriesProducts)//汽车类别,汽车品牌,产品系列    {}//构造函数 friend ostream & operator<<(ostream &out,Vehicle &v);
};
//重载输出流
ostream & operator<<(ostream &out,Vehicle &v){out<<"交通类别:"<< v.VehicleCategory<<endl;out<<v.am;return out;
}int main(){Vehicle p = Vehicle("私人汽车","豪华轿车","奥迪","奥迪8系"); cout<<p;
}

04737 c++ 自学考试2019版 第五章程序设计题 1相关推荐

  1. 04737 c++ 自学考试2019版 第四章课后程序设计题1

    /** * 04737 c++ 自学考试2019版 * 第四章程序设计题1 * 为程序4-2中的类myComplex重载乘法运算符 */ #include <iostream>//标准流 ...

  2. 04737 c++ 自学考试2019版 第六章课后练习 程序设计题 1

    /* * 04737 c++ 自学考试2019版 第六章课后练习 * 程序设计题 1 * 需求:将第五章习题中设计的交通工具...... */#include<iostream> #inc ...

  3. 04737 c++ 自学考试2019版 第四章课后练习 程序设计题 2

    /* * 04737 c++ 自学考试2019版 第四章课后练习 * 程序设计题 2 * 需求:为第二章习题设计中的二维坐标系下的类point,重载<< >> */ //标准流 ...

  4. 04737 c++ 自学考试2019版 第二章课后程序设计题 3

    /* * 04737 c++ 自学考试2019版 第二章课后练习 * 程序设计题 3 * 需求:设计并实现一个类MyLine */ //标准流 #include<iostream> //科 ...

  5. 04737 c++ 自学考试2019版 第二章课后程序设计题 2

    /* * 04737 c++ 自学考试2019版 第二章课后练习 * 程序设计题 2 * 需求:设计并实现二维坐标系下点的类Point.... */ //标准流 #include<iostrea ...

  6. 编译原理陈火旺版第五章课后题答案

    下面答案仅供参考! 1.令文法G为: E→E+T∣T T→T*F∣F F→(E)∣i 证明E+T*F是它的一个句型,指出这个句型的所有短语,直接短语和句柄. 2.考虑下面的表格结构文法G2: S→a∣ ...

  7. c语言程序设计现代方法第二版 第10章程序设计题3题,自己编写的一个程序

    main.c文件 #include <stdio.h> //#include "lib.h" if there is a statement like this ,th ...

  8. 贝叶斯统计第二版第五章答案_贝叶斯统计第二部分

    贝叶斯统计第二版第五章答案 In this post, I will compare the output of frequentist and Bayesian statistics, and ex ...

  9. 数据库系统概念第六版 第五章练习题 2 4

    数据库系统概念第六版 第五章练习题 2 4 5.2 写一个使用JDBC元数据特性的JAVA函数,该函数用ResultSet作为输入参数,并把结果输出为用合适的名字作为列名的表格形式. (对JAVA不太 ...

最新文章

  1. 利用单片机快速实现家庭智能控制平台
  2. oracle连接数据的oci和thin的区别
  3. 浅析epoll – epoll例子以及分析
  4. (原创总结) Quartus II 的在线调试方法
  5. 《网络空间欺骗:构筑欺骗防御的科学基石》一1.1 主动网络空间防御中网络空间抵赖与欺骗的视图...
  6. python调用.a静态库_Python 调用 C
  7. Java笔记-C3P0连接池中常用的3个配置
  8. java hibernate 分页取数_java – Hibernate分页机制
  9. docker开机启动失败_Docker教程(二)——安装Docker
  10. php yii2 观察者模式,观察者模式(Observer)
  11. 用于创建此对象的程序是excel_一起学Excel专业开发22:使用类模块创建对象1
  12. 计算机二级c语言带小抄,计算机二级C语言上机题库(可缩印做小抄)..docx
  13. 软件数字签名证书选购指南
  14. wordpress连接mysql数据库_wordpress远程连接mysql数据库方法
  15. 数字化转型,金融行业的下一个引爆点
  16. 滑动鼠标滚轮后浏览器页面抖动
  17. oracle 固定顺序排序
  18. dij与prim算法
  19. 人间清醒,内容为王 - 技术er究竟该如何写博客?1024上海嘉年华之敖丙演讲观后感。
  20. Linuc云面板---旗鱼云梯操作使用说明

热门文章

  1. jquery 与 prototype 冲突 Using jQuery with Other Libraries
  2. setsockopt函数功能介绍
  3. go语言sleep一纳秒不准的思考--CPU时间片
  4. 数据结构——树的存储结构孩子表示法
  5. 【AI视野·今日CV 计算机视觉论文速览 第217期】Thu, 10 Jun 2021
  6. 【AI视野·今日CV 计算机视觉论文速览 第204期】Mon, 24 May 2021
  7. 文件流对象 c# 1614525948
  8. 02 理解==与Equals()的区别及用法 1214
  9. mysql安装笔记190914
  10. django-查询-F对象-Q对象