适配器模式 C++实现
来源:互联网 发布:淘宝客服工作流程表 编辑:程序博客网 时间:2024/05/16 16:58
#include<iostream>#include<string>#include<cstdlib>using namespace std;/*适配器模式class target是接口, adapter 才是封装需要适配类(class adaptee)的适配器。 主要思想是将需要适配的class 在class adapter 中进行封装。 */ class target{ public: virtual void request() { cout <<"Ordinary request!"<< endl; } };class adaptee{ public: void special_request() { cout <<"Special request !"<< endl; } };class adapter: public target{ private: adaptee *my_adaptee; //问题: 为什么不用初始化这个类指针? public: void request() { my_adaptee->special_request(); } };int main(){ target *my_target = new adapter(); my_target->request(); system("pause"); return 0; }
总结:无。
- 适配器模式C语言实现
- 接口模式 - 1.1 适配器模式 --代码实现(C#)
- 【C++】Chapter13:适配器模式
- Objective C--适配器模式
- Objective C 适配器模式
- 适配器模式(C++)
- 适配器模式(C++)
- php实现适配器模式
- C++实现适配器模式
- 适配器模式 C++实现
- 适配器模式lua实现
- php实现适配器模式
- 适配器模式C++实现
- java实现适配器模式
- 适配器模式实现
- 适配器模式 C++实现
- 适配器模式C++实现
- 适配器模式(java实现)
- 多版本Python共存[支持使用pip安装包]
- hdu play on words(大神写的)
- 研磨JavaScript系列(二):没有类
- 表达式树
- 乘法算式
- 适配器模式 C++实现
- 关于c 语言处理变长参数问题
- multithreadqueue
- android camera 照片旋转了90度
- 动规-买车票(Ural1031)
- 为什么我觉得单片机开发比FPGA开发要难
- TopFreeTheme精选免费模板【20130617】
- Python模块学习 ---- datetime
- MotionEvent(二) 多点触摸