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

📄 delegation.cpp

📁 设计模式 几个常见的设计模式源代码 Delegation Factory等
💻 CPP
字号:
#include <iostream>
using namespace std;

class Rectangle
{
public:
	Rectangle( int height, int width ) : _height( height ), _width( width )
	{
	}

public:
	int Area()
	{
		return _height*_width;
	}
	
private:
	int _height;
	int _width;
};

class Target
{
	virtual int Area() = 0;
};

class Window : public Target
{
public:
	Window( Rectangle& rect ) : _rect( rect )
	{
	}
public:
	int Area()
	{
		return _rect.Area();
	}
	
private:
	Rectangle& _rect;
};

int main()
{
	Rectangle rect( 10, 20 );
	Window win( rect );
	win.area();	
	
	return 0;
}

⌨️ 快捷键说明

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