首页 > 代码库 > Adapter
Adapter
#include <iostream>using namespace std;class ThirdPartImpl{public: void SomeFunction() { cout<<"ThirdPartImpl::SomeFunction"<<endl; }};class Target{public: virtual void SomeRequest()=0;};class Adapter : public Target{public: Adapter() { m_pImpl = new ThirdPartImpl; } ~Adapter() { delete m_pImpl; } void SomeRequest() { m_pImpl->SomeFunction(); } private: ThirdPartImpl* m_pImpl;};int main(int argc, char *argv[]){ Target* pTarget = new Adapter; pTarget->SomeRequest(); delete pTarget; pTarget = NULL; return 0;}
Adapter
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。