码迷,mamicode.com
首页 > 其他好文 > 详细

Proxy

时间:2014-12-11 10:21:05      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   os   sp   on   div   

#include <iostream>

using namespace std;



class Product
{
public:
    virtual ~Product() {}
    virtual void Action()=0;
};


class ConcreteProduct : public Product
{
public:
    ConcreteProduct() {}
    ~ConcreteProduct() {}

    void Action()
    {
        cout<<"ConcreteProduct::Action"<<endl;
    }
};



class SaleProxy : public Product
{
public:
    SaleProxy()
    {
        m_pProduct = new ConcreteProduct;
    }
    ~SaleProxy()
    {
        delete m_pProduct;
        m_pProduct = NULL;
    }

    void Action()
    {
        cout<<"SaleProxy::";
        m_pProduct->Action();
    }

private:
    Product* m_pProduct;
};



int main(int argc, char *argv[])
{
    ConcreteProduct realProduct;
    realProduct.Action();

    SaleProxy proxy;
    proxy.Action();

    
    return 0;
}

 

Proxy

标签:style   blog   io   ar   color   os   sp   on   div   

原文地址:http://www.cnblogs.com/stanley198610281217/p/4156840.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!