首页 > 其他 > 详细

Adapter

时间:2014-12-10 15:55:11      阅读:264      评论:0      收藏:0      [点我收藏+]
#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

原文:http://www.cnblogs.com/stanley198610281217/p/4155363.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!