外观模式--我无法领悟的简单

这么简单的家伙也是设计模式之一?
我的理解就是多了一层封装的接口而已。
可能是我的理解不够透彻,或者说我理解有误。


#include <iostream>
#include <conio.h>

class SubSystemOne
{
public:
	void work()
	{
		printf("one is work\r\n");
	}
};

class SubSystemTwo
{
public:
	void work()
	{
		printf("two is work\r\n");
	}
};

class SubSystemThree
{
public:
	void work()
	{
		printf("three is work\r\n");
	}
};

class SubSystemFour
{
public:
	void work()
	{
		printf("four is work\r\n");
	}
};

class Facade
{
private:
	SubSystemOne m_One;
	SubSystemTwo m_Two;
	SubSystemThree m_Three;
	SubSystemFour m_Four;

public:

	void MethodA()
	{
		printf("Method A\r\n");
		m_One.work();
		m_Four.work();
	}

	void MethodB()
	{
		printf("Method B\r\n");
		m_Two.work();
		m_Three.work();
	}
};


int main()
{
	Facade f;
	f.MethodA();
	f.MethodB();
	getch();
	return 0;
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值