/********************************* *设计模式--适配器2模式实现 *C++语言 *Author:WangYong *Blog:http://www.cnblogs.com/newwy ********************************/ #include <iostream> using namespace std; class Target { public: virtual ~Target(){} virtual void Request(){cout<<"Target::Request"<<endl;} }; class Adaptee { public: Adaptee(){} ~Adaptee(){} void SpecificRequest(){cout<<"Adaptee::SpecificRequest"<<endl;} }; class Adapter:public Target, private Adaptee { public: Adapter(Adaptee * ade){this->_ade = ade;} ~Adapter(){} void Request(){_ade->SpecificRequest();} private: Adaptee *_ade; }; int main() { Adaptee *ade = new Adaptee; Target *adt = new Adapter(ade); adt->Request(); return 0; }