码迷,mamicode.com
首页 > 其他好文 > 详细

Adapter

时间:2014-12-10 15:57:41      阅读:152      评论:0      收藏:0      [点我收藏+]

标签:style   blog   io   ar   color   os   sp   on   div   

#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

标签:style   blog   io   ar   color   os   sp   on   div   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!