外观模式:指的是为一组具有类似功能的类群,如类库,子系统等,提供一个一致的简单页面
外观模式为子系统统一一套接口,使子系统更加容易使用
class SubSystemA {
public:
void doThing() {
cout << "SubSystemA doThing----" << endl;
}
};
class SubSystemB {
public:
void doThing() {
cout << "SubSystemB doThing----" << endl;
}
};
class SubSystemC {
public:
void doThing() {
cout << "SubSystemC doThing----" << endl;
}
};
class Facade
{
public:
Facade()
{
a = new SubSystemA;
b = new SubSystemB;
c = new SubSystemC;
}~Facade()
{
delete a;
delete b;
delete c;
}
void doThing()
{
a->doThing();
b->doThing();
c->doThing();
}
protected:
private:
SubSystemA* a;
SubSystemB* b;
SubSystemC* c;
};
int main()
{
Facade* f = new Facade;
f->doThing();
delete f;
system("pause");
return 0;
}