1.主要思想:将一个类的接口转换成客户希望的另外一个接口。Adapter模式使得原本由于接口不兼容而不能一起工作的那些类可以一起工作。

      对于不同的客户我们可以这样使用适配器模式。

2.实现方法:

#include<iostream>
using namespace std; // "ITarget"
class Target
{
public:
// Methods
virtual void Request(){};
}; // "Adaptee"
class Adaptee
{
public:
// Methods
void SpecificRequest()
{
cout<<"Called SpecificRequest()"<<endl;
}
}; // "Adapter"
class Adapter : public Adaptee, public Target
{
public:
// Implements ITarget interface
void Request()
{
// Possibly do some data manipulation
// and then call SpecificRequest
this->SpecificRequest();
}
}; int main()
{
// Create adapter and place a request
Target *t = new Adapter();
t->Request(); return ; }

最新文章

  1. 试图加载格式不正确的程序。 (异常来自HRESULT:0x8007000B)
  2. iOS AFOAuth2Manager使用心得
  3. css学习中的一些英文单词
  4. TCP/IP 端口号大全
  5. 依赖注入Bean属性
  6. DOM 节点实例操作
  7. SurfaceView绘图机制
  8. 自定义清除重复uses-permission申明的AS插件
  9. JMeter怎么在get URL请求、POST请求中添加动态参数用于服务器段安全验证
  10. Java-List泛型的用处(能够使用传入泛型对象的方法)
  11. Quirks模式是什么?它和Standards模式有什么区别
  12. 【Jquery系列】详解Jquery对象和Dom对象
  13. 强化学习(五)用时序差分法(TD)求解
  14. Nginx从入门到实践(二)
  15. JAVA项目中文件重命名方式
  16. vue 图片切换动态绑定
  17. __AFO
  18. window7开启Administrator账户
  19. Linux下Oracle常用命令
  20. extends android.view.ViewGroup两种实现

热门文章

  1. 0704 Process继承实现多进程、Pool进程池,进程间通过队列通信,Pool实现多进程实现复制文件
  2. 字符串——cf1109B
  3. eclipse查看源码的配置
  4. NPM 使用介绍(包管理工具,解决NodeJS代码部署上的很多问题)
  5. hexo next中遇到的bug,引发出的关于jquery中click()函数和on("click",function())的区别
  6. Spring Boot 发布 jar 包转为 war 包秘籍。
  7. 2_2.springboot2.x配置之自动配置原理
  8. SSM三大框架的运行流程、原理、核心技术详解
  9. nginx 配置文件备份 nginx.conf and vhosts
  10. linux centos&amp;Ubuntu&amp;RedHat更换软件源