外观模式(C++)

#include 
using namespace std;

class subsys1
{
public:
    subsys1(){}
    ~subsys1(){}
    void operation(){cout<<"subsys1"<<endl;}
};

class subsys2
{
public:
    subsys2(){}
    ~subsys2(){}
    void operation(){cout<<"subsys2"<<endl;}
};

class subsys3
{
public:
    subsys3(){}
    ~subsys3(){}
    void operation(){cout<<"subsys3"<<endl;}
};

class facade
{
public:
    facade(){}
    ~facade(){}
    void mathod1()
    {
        sb1->operation();
        sb2->operation();
    }

    void mathod2()
    {
        sb2->operation();
        sb3->operation();
    }

private:
    subsys1 *sb1;
    subsys2 *sb2;
    subsys3 *sb3;
};

int main()
{
    facade *fac=new facade;
    fac->mathod1();
    fac->mathod2();
    delete fac;

    system("pause");
    return 0;
}

转载于:https://www.cnblogs.com/tiandsp/archive/2012/06/26/2563854.html

你可能感兴趣的:(外观模式(C++))