zoukankan      html  css  js  c++  java
  • 设计模式——外观模式(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.....
  • 相关阅读:
    【团队分享之二】IT团队绩效提升的一些见解
    我的ef连接mysql之旅
    Python3.5-20190501-廖老师的
    新装ubantu 18.04(自用)
    nginx配置url重写
    docker中crontab无法执行
    bootstrap
    mysql set
    mysqldump导出数据
    XGBoost 学习调参的例子
  • 原文地址:https://www.cnblogs.com/070412-zwc/p/6844044.html
Copyright © 2011-2022 走看看