/********************************* *设计模式--适配器1模式实现 *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(){} ~Adapter(){} void Request(){this->SpecificRequest();} }; int main() { Target *adt = new Adapter(); adt->Request(); return 0; }