标签:c++ 设计模式
//Facade.h #include "stdafx.h" #include <iostream> using namespace std; class SubSystemOne { public : void MethodOne() { cout << "MethodOne!" << endl; } }; class SubSystemTwo { public : void MethodTwo() { cout << "MethodTwo!" << endl; } }; class SubSystemThree { public : void MethodThree() { cout << "MethodThree!" << endl; } }; class Facade { private : SubSystemOne * m_pSubSystemOne; SubSystemTwo * m_pSubSystemTwo; SubSystemThree * m_pSubSystemThree; public : Facade() { m_pSubSystemOne = new SubSystemOne (); m_pSubSystemTwo = new SubSystemTwo (); m_pSubSystemThree = new SubSystemThree (); } void MethodA() { cout << "方法组A" << endl; m_pSubSystemOne->MethodOne(); m_pSubSystemTwo->MethodTwo(); m_pSubSystemThree->MethodThree(); } void MethodB() { cout << "方法组B" << endl; m_pSubSystemTwo->MethodTwo(); m_pSubSystemThree->MethodThree(); } };
// FacadePattern.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include "Facade.h" int _tmain (int argc , _TCHAR * argv []) { Facade facade; facade.MethodA(); facade.MethodB(); getchar(); return 0; }
标签:c++ 设计模式
原文地址:http://blog.csdn.net/wwwdongzi/article/details/27343739