其他分享
首页 > 其他分享> > 量化交易之设计模式篇 - 外观模式

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

作者:互联网

//
// 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;
}

标签:外观,three,two,fac,new,Facade,量化,设计模式,delete
来源: https://blog.csdn.net/Michael_234198652/article/details/123170770