Expressed 16 design patterns with 32 lines of code

zhaozj2021-02-11  173

In order to demonstrate the following 16 modes, the following 32 line code is used. iterator, adapter, interpreter, proxy, state, visitor, command, bridge, chain of responsibility, composite, flyweight, strategy, decorator, mediator, memento, observervoid main () {for (i = 0; i <2; i ) { IF (i == 0) {actor getupactor = new getupactor (); getUpactor.Action (); delete getupactor;} else if (i == 1) {actor Suppector = new supportor (); suppeteor.action (); delete Suppector;}} class actor () {public: Virtual void action () = 0; protected: actor ();}; class getupactor (): public actor {public: virtual void action (); getuPactor ();}; void GetUpactor: action {cout << "Getting up";

转载请注明原文地址:https://www.9cbs.com/read-5190.html

New Post(0)