callmeFilip / Thinking-in-CPP-Volume-1-2nd-Edition

Homework and Classwork repository
0 stars 0 forks source link

Chapter_14 Task_27 #292

Open callmeFilip opened 3 years ago

callmeFilip commented 3 years ago

This exercise creates the design pattern called proxy. Start with a base class Subject and give it three functions: f( ), g( ), and h( ). Now inherit a class Proxy and two classes Implementation1 and Implementation2 from Subject. Proxy should contain a pointer to a Subject, and all the member functions for Proxy should just turn around and make the same calls through the Subject pointer. The Proxy constructor takes a pointer to a Subject that is installed in the Proxy (usually by the constructor). In main( ), create two different Proxy objects that use the two different implementations. Now modify Proxy so that you can dynamically change implementations.