设计模式——外观模式(C++实现)
1 #include <string> 2 #include <iostream> 3 4 using namespace std; 5 6 class STSystemA 7 { 8 public: 9 void OperationA() 10 { 11 cout<< "System A Operation....."<< endl; 12 } 13 }; 14 15 class STSystemB 16 { 17 public: 18 void OperationB() 19 { 20 cout<< "System B Operation....."<< endl; 21 } 22 }; 23 24 class STSystemC 25 { 26 public: 27 void OperationC() 28 { 29 cout<< "System C Operation....."<< endl; 30 } 31 }; 32 33 class STFacade 34 { 35 public: 36 STFacade() 37 { 38 m_stSystemA = new STSystemA(); 39 m_stSystemB = new STSystemB(); 40 m_stSystemC = new STSystemC(); 41 } 42 43 virtual ~STFacade() 44 { 45 delete m_stSystemA; 46 delete m_stSystemB; 47 delete m_stSystemC; 48 } 49 50 void Operation() 51 { 52 m_stSystemA->OperationA(); 53 m_stSystemB->OperationB(); 54 m_stSystemC->OperationC(); 55 } 56 57 STSystemA* m_stSystemA; 58 STSystemB* m_stSystemB; 59 STSystemC* m_stSystemC; 60 61 }; 62 63 64 int main(int argc, char* argv[]) 65 { 66 STFacade* stFacade = new STFacade(); 67 stFacade->Operation(); 68 69 delete stFacade; 70 71 return 0; 72 } 73 ///////////////////////////////////// 74 [root@ ~/learn_code/design_pattern/11_facade]$ ./facade 75 System A Operation..... 76 System B Operation..... 77 System C Operation.....
相关推荐
olyqcool 2020-05-04
特 2012-10-21
huangzhe0 2011-09-30
onfund 2019-06-26
liyifan 2013-09-23
MarkArch 2019-06-21
JeremyZJM 2018-12-21
PHPArchitect 2018-03-28
airfling 2015-02-23
pythoning 2019-01-17
ljscoding 2016-05-18
舍 2016-03-16
PHP100 2019-03-28
PHP100 2019-03-27
vczh的日常 2018-04-18
编程语言与高级语言虚拟机杂谈仮 2018-04-16
前端外刊评论 2018-03-14
迷思 2017-10-11