#include <iostream> #include <memory> class Subject { public: virtual void show() = 0; }; class RealSubject : public Subject { public: void show() override { std::cout << "In RealSubject show()." << std::endl; } }; class Proxy : public Subject { public: void show() override { std::cout << "In Proxy show()." << std::endl; rs.show(); } private: RealSubject rs; }; int main(int argc, char *argv[]) { std::unique_ptr<Subject> s = std::make_unique<Proxy>(); s->show(); return 1; }