/* class_adapter.cpp * * Adapter objects get their functionality through inheritance * from class Target */ #include #include class Interface { public: virtual void request() = 0; }; class Target { public: virtual void specificRequest() { std::cout << "Using specific request\n"; } }; class Adapter: public Interface, private Target { public: virtual void request(){ specificRequest(); } }; class Client { public: Client(Interface* interface) : _interface(interface) {} void do_something() { _interface->request(); } private: Interface* _interface; }; int main() { Adapter a; Client client(&a); client.do_something(); }