代码实现:
#include <iostream>
#include <list>
#include <string>
using namespace std;
class SubsystemA
{
public:
void doThing()
{
cout << "SubsystemA do thing" << endl;
}
};
class SubsystemB
{
public:
void doThing()
{
cout << "SubsystemB do thing" << endl;
}
};
class SubsystemC
{
public:
void doThing()
{
cout << "SubsystemC do thing" << endl;
}
};
class Facade
{
public:
Facade()
{
subsystemA = new SubsystemA;
subsystemB = new SubsystemB;
subsystemC = new SubsystemC;
}
~Facade()
{
delete subsystemA;
delete subsystemB;
delete subsystemC;
}
void doThing() {
subsystemA->doThing();
subsystemB->doThing();
subsystemC->doThing();
private :}
SubsystemA* subsystemA;
SubsystemB* subsystemB;
SubsystemC* subsystemC;
};
void main()
{
Facade* facade = new Facade;
facade->doThing();
}