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

📄 e3.cpp

📁 能理解C++中运算符重载的需要性
💻 CPP
字号:
#include<iostream.h>          

class Furniture
{
public:
	Furniture(){}
	void SetWeight(int i){weight=i;}
	int GetWeight(){return weight;}
protected:
	int weight;
};
class Bed:public Furniture
{
public:
	Bed(){}
	void Sleep()
	{
		cout<<"Sleep..."<<endl;
	}
};
class Sofa:public Furniture
{
public:
	Sofa(){}
	void WatchTV()
	{
		cout<<"Watching TV."<<endl;
	}
};
class SleepSofa:public Bed,public Sofa
{
public:
	SleepSofa():Sofa(),Bed(){}
	void FoldOut()
	{
		cout<<"Fold out the sofa."<<endl;
	}
};
void main()
{
	SleepSofa ss;
	ss.SetWeight(20);
}

⌨️ 快捷键说明

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