#include <iostream.h>
#include <typeinfo.h>
class Father{
friend class Mother;
public:
Father(){ cout << "father is created.\n "; }
void DoWork(){ DriveACar(); }
void DoMannulWork(){ RepairTV(); }
void DriveACar() { cout <<"Drive a car.\n "; }
protected:
void RepairTV() { cout <<"Repair a TV set.\n "; }
};
class Mother{
public:
Mother(){ cout << "mother is created.\n "; }
void SingASong() { cout << "Sing a song.\n "; }
void DoWork(){ SingASong(); } //正式工
void DoMannulWork() { cout << "Do mannul work.\n "; } //小工
};
class Boy: public Father, public Mother{
public:
Boy(){ cout << "boy is created.\n "; }
void DriveACar() { cout << "boy: "; Father::DriveACar(); }
void RepairTV(){ cout << "boy:"; Father::RepairTV(); }
void SingASong(){ cout << "boy:"; Mother::SingASong(); }
void PlayPingPong(){ cout << "boy:Play pingpong.\n "; };
};
void main()
{
Father father;
Mother mother;
Boy boy;
cout << "father:";
father.DoWork();
cout << "mother:";
mother.DoWork();
cout << "mother:";
mother.DoMannulWork();
boy.PlayPingPong();
cout << "father come back! "<< endl;
boy.DriveACar();
boy.SingASong();
cout << "father: ";
father.DoMannulWork();
boy.RepairTV();
}
A-family-of-3.zip_T5U_family_一个三口之家
版权申诉
5星 · 超过95%的资源 140 浏览量
2022-09-20
22:05:11
上传
评论 1
收藏 640B ZIP 举报
JonSco
- 粉丝: 67
- 资源: 1万+
最新资源
- 王姿.html
- 51单片机学习(1)-软件keil下载
- 历届(第1-21届)希望杯数学竞赛初一试题及答案(最新整理).doc全国数学邀请赛(264页资料)
- 水滴.psd
- TokenPocket_V2.1.2_release.apk
- Apache-druid-kafka-rce.yaml
- 基于C#的ASP.NET数据库原理及应用技术课程指导平台的开发
- 基于ROS的智能车轨迹跟踪算法的仿真与设计源码运用PID跟踪算法.zip.zip
- Bug Bounty Tip - i春秋Self-XSS变废为宝的奇思妙想
- 1991-2015年全国初中化学竞赛复赛试题汇编(212页)(24年竞赛复赛真题).docx天原杯
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论10