量化交易之设计模式篇 - 外观模式

//
// Created by win10 on 2021/11/16.
//

#include <thread>
#include <iostream>
using namespace std;

/* 外观模式
 *
 */
class SubSysOne {
public:
    void method1() {
        std::cout << "method 1" << std::endl;
    }
};
class SubSysTwo {
public:
    void method2() {
        std::cout << "method 2" << std::endl;
    }
};
class SubSysThree {
public:
    void method3() {
        std::cout << "method 3" << std::endl;
    }
};

// 外观类
class Facade {
public:
    Facade() {
        this->one = new SubSysOne();
        this->two = new SubSysTwo();
        this->three = new SubSysThree();
    }
    virtual ~Facade() {
        delete this->one;
        delete this->two;
        delete this->three;
    }

    void show() {
        this->one->method1();
        this->two->method2();
        this->three->method3();
    }

private:
    SubSysOne* one;
    SubSysTwo* two;
    SubSysThree* three;
};

int main() {

    Facade* fac = new Facade();
    fac->show();

    delete fac;
    return 0;
}

上一篇:Windows系统安装Elasticsearch


下一篇:数据存储和云安全是选择云服务的关键