适配器模式
来源:互联网 发布:python虚拟主机 编辑:程序博客网 时间:2024/05/20 21:57
#include<iostream>
using namespace std;
class Target
{
public:
virtual void Request()
{
cout<<"普通请求"<<endl;
}
};
//需要适配的
class Adaptee
{
public:
void SpecialRequest()
{
cout<<"特殊请求"<<endl;
}
};
class Adapter:public Target
{
private:
Adaptee* adaptee()
{
return new Adaptee();
}
public:
void Request()
{
adaptee()->SpecialRequest();
}
};
int main()
{
Target* target=new Target();
target->Request();
target=new Adapter();
target->Request();
return 0;
}
using namespace std;
class Target
{
public:
virtual void Request()
{
cout<<"普通请求"<<endl;
}
};
//需要适配的
class Adaptee
{
public:
void SpecialRequest()
{
cout<<"特殊请求"<<endl;
}
};
class Adapter:public Target
{
private:
Adaptee* adaptee()
{
return new Adaptee();
}
public:
void Request()
{
adaptee()->SpecialRequest();
}
};
int main()
{
Target* target=new Target();
target->Request();
target=new Adapter();
target->Request();
return 0;
}
0 0
- 适配器及适配器模式
- 适配器及适配器模式
- 适配器模式(类适配器)
- 适配器模式(默认适配器)
- 适配器模式(对象适配器)
- 适配器模式-类适配器
- 适配器模式-对象适配器
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- 适配器模式
- gluster的迁移
- 简单,是一种大美
- mysql 编号生成
- g++编译中遇到undefined reference to `GetAdaptersInfo@8'处理方法
- C#学习笔记之初识LINQ查询
- 适配器模式
- ibus五笔造词、删词功能
- Infobright高性能数据仓库
- between and 函数
- Android横竖屏切换和灭屏亮屏时Activity的生命周期探究
- VLAN三种模式
- python tab键补全功能
- Eclipse快捷键大全(转载)
- Frame里打开IE10 IE11 showModalDialog大小调整