Proxy
#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; }