门面模式,是指提供一个统一的接口去访问多个子系统的多个不同的接口,它为子系统中的一组接口提供一个统一的高层接口。使用子系统更容易使用。
例子如下,完成program任务,内部完成 code compile run任务
#include "iostream" using namespace std; class code{ public: void active(){ cout<<"finish code"<<endl; } }; class compile{ public: void active(){ cout<<"finish compile"<<endl; } }; class run{ public: void active(){ cout<<"finish run"<<endl; } }; class program{ public: program(){ pcode = new code; pcompile = new compile; prun = new run; } ~program(){ delete pcode; delete pcompile; delete prun; } void dotask(){ pcode->active(); pcompile->active(); prun->active(); cout<<"the task to program is finished"<<endl; } private: code * pcode; compile * pcompile; run * prun; }; int main(int argc, char* argv[]) { program * pprogram = new program; pprogram->dotask(); return 0; }