代理模式
代码逻辑
class Factory
{
public:
virtual void makeProduct() =0;
};
class PhoneFactory :public Factory
{
public:
void makeProduct()
{
cout<<"生产手机"<<endl;
}
};
class FoxconnProxy :public Factory
{
public:
FoxconnProxy(Factory* factory )
{
m_real = factory;
}
void makeProduct()
{
m_real->makeProduct();
}
private:
Factory *m_real;
};
void main()
{
Factory *factory = new PhoneFactory();
FoxconnProxy * proxy = new FoxconnProxy(factory);
proxy->makeProduct();
}
1611

被折叠的 条评论
为什么被折叠?



