适配器模式,Adapter

适配器模式,Adapter

将一个类的接口转换成客户希望的另外一个接口。

结构型模式简介

http://blog.163.com/zhoumhan_0351/blog/static/39954227201042884015161/

对象适配器维护了一个Adaptee的接口。

class Target{

Target(){}

//...request

};

class Adaptee{

Adaptee(){}

//...some operation

};

class Adapter:public Target{

Adapter(){}

    Adapter(Adaptee* _adaptee){

this->_adaptee=_adaptee;

}

//...定义一些接口,将_adaptee的接口改写成Target所能操作的接口

private:

Adaptee* _adaptee;

}

发布了81 篇原创文章 · 获赞 17 · 访问量 6018

猜你喜欢

转载自blog.csdn.net/hopegrace/article/details/103870710