Proxy design mode. This mode is mostly used for server clients and the like. It is very complicated to think of, but this design mode is very simple.
A class calls a function of another class. The customer calls a class, and the actual work is done by another class.
Code that reflects this design pattern:
# Include <stdio. h> class realobj {public: Virtual void handlereq () = 0 ;}; class dosomething: Public realobj {public: void handlereq () {puts ("Actually, I will do the rest... ") ;}}; class proxy {realobj * subject; public: proxy (realobj * sub): subject (sub) {} virtual ~ Proxy () {If (subject) delete subject;} void request () {puts ("proxy request... using other object to requese. "); Subject-> handlereq (); // just simply call a function, using another object .}}; int main () {realobj * sub = new dosomething; proxy P (sub); p. request (); Return 0 ;}
Run: