适配器模式C++实现
2021-01-20 14:13
阅读:626
标签:stream spec main vat lan info public 适配器模式 mamicode
目录
- 类适配器
- 对象适配器
类适配器
#include
using namespace std;
// Target
class Target {
public:
virtual void Request() {
cout Request();
if (pTarget) delete pTarget;
return 0;
}
对象适配器
#include
using namespace std;
// Target
class Target {
public:
Target(){}
virtual ~Target(){}
virtual void Request() {
cout SpecificRequest();
}
private:
Adaptee *m_Adaptee;
};
// Client
int main() {
Target * pTarget = new Adapter();
pTarget->Request();
if (pTarget) delete pTarget;
return 0;
}
适配器模式C++实现
标签:stream spec main vat lan info public 适配器模式 mamicode
原文地址:https://www.cnblogs.com/wstong/p/12901003.html
上一篇:Java函数式编程(一)
评论
亲,登录后才可以留言!