⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 练习.txt

📁 钱能主编 C++程序设计教程(第一版) 该书习题的答案代码
💻 TXT
字号:
//************************
//**      main.cpp      **
//************************
#include <iostream.h>
#include "famo.h"

void main()
{
	Father fa;
	Mother mo;
	Child  ch;

	cout<<"a new day start..."<<endl;
	cout<<"father:"; fa.Drive();
	cout<<"mother:"; mo.Sing(); mo.PJ();
	cout<<"child:";  ch.PlayBall();

	cout<<endl<<"then father drive back..."<<endl;
	cout<<"child:";  ch.Drive(); ch.Sing();
	
	cout<<endl<<"in the evening..."<<endl;
	cout<<"father:"; fa.Mend();
	cout<<"child:";  ch.Mend();
}
//**********************
//**      famo.h      **
//**********************
#include <iostream.h>

class Father
{
public:
	void Drive() {cout<<"driving car."<<endl;}
	void Mend() {MendTV();}
protected:
	void MendTV() {cout<<"repair TV."<<endl;}
};

class Mother
{
public:
	void Sing() {cout<<"singing."<<endl;}
	void PJ() {PartJob();}
private:
	void PartJob() {cout<<"doing parttime job."<<endl;}
};

class Child:public Father,public Mother
{
public:
	void PlayBall() {cout<<"playing ball."<<endl;}
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -