适配器模式C++实现
标签: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
文章来自:
搜素材网的
编程语言模块,转载请注明文章出处。
文章标题:
适配器模式C++实现
文章链接:http://soscw.com/index.php/essay/44565.html
评论