代理类
来源:互联网 发布:电影源码带采集 编辑:程序博客网 时间:2024/05/22 03:49
Implementation.h
class Implementation{public:Implementation(int v) :value(v){}void setValue(int v){value=v; }int getValue() const{ return value; } private:int value;};
Interface.h
class Interface{public:Interface(int);void setValue(int);int getValue() const;~Interface(); private:Implementation *ptr;};
Interface.cpp
#include“Implementation.h”Interface::interface(int v) :ptr(new Imlementation(v)){}void Interface::setValue(int v){ptr->setValue(v);}int Interface::getValue() const{return ptr->getValue();}Interface::~Interface(){delete ptr;}demo.cpp
#include<iostream>using namespace std;#incldue"INterface.h"int main(){Interface i(5); cout<<i.getValue(); i.setValue(10); cout<<i.getValue()<<endl; return 0;}结果:
5
10
0 0
- 代理类
- 代理类
- 代理类
- 代理类
- 代理类
- 代理类
- 代理类
- 代理类
- 代理类
- 代理类
- 代理模式与Java动态代理类
- 代理模式与Java动态代理类
- java代理模式及动态代理类
- java动态代理-生成代理类
- (静态代理模式)代理类的作用
- 代理类(Surrogate)
- WebService代理类
- TRSProxy Recordset 代理类
- winform 五子棋 判断输赢
- hdu 1175 连连看(模拟循环队列)
- POJ3264_Balanced Lineup(线段树/单点更新)
- Python 字符串
- 6.2单链表
- 代理类
- C++ MFC连接mysql
- 黑马程序员_面向对象_继承多态
- 北大oj--1050
- 格式化时间
- 二分图匹配之匈牙利算法和 二分图匹配的几种题型
- Message Flood
- HDU 1026 Ignatius and the Princess I 记录 路径广搜
- jquery中form中使用submit出现的问题,未解决