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;
}