Welcome to tiger's blog!

What lead to success, what we are seeking...
posts - 47, comments - 23, trackbacks - 0, articles - 8
   :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理

设计模式(Facade)

Posted on 2007-04-13 09:44 tiger 阅读(316) 评论(0)  编辑 收藏 引用

#include <iostream>
using namespace std;

class CSubSystem1
{
public:
 CSubSystem1(){}
 virtual ~CSubSystem1(){}

public:
 void Func(){cout<<"SubSystem1!"<<endl;}

};

class CSubSystem2
{
public:
 CSubSystem2(){}
 virtual ~CSubSystem2(){}

public:
 void Func(){cout<<"SubSystem2!"<<endl;}

};

class CFacade
{
public:
 CFacade();
 virtual ~CFacade();

public:
 void Func();

private:
 CSubSystem1 *m_pSubSystem1;
 CSubSystem2 *m_pSubSystem2;

};

CFacade::CFacade()
{
 m_pSubSystem1 = new CSubSystem1();
 m_pSubSystem2 = new CSubSystem2();
}

CFacade::~CFacade()
{
 delete m_pSubSystem1;
 delete m_pSubSystem2;
}

void CFacade::Func()
{
 m_pSubSystem1->Func();
 m_pSubSystem2->Func();
}

void main()
{
 CFacade *pFacade = new CFacade();
 pFacade->Func();
 delete pFacade;
}


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   博问   Chat2DB   管理