Objective: Create a class to manage the processing of a series of events. Or based on the current status to call different status processing functions. Of course, this feature can be implemented by simple Switch. But use Switch's implementation is not high, it is not easy to maintain, and There is no good adaptability for changes in the demand, which is not good for the code. The following is an example of using the Switch implemented according to but the pre-status call different processing functions: Class Robot {public: Virtual Void Update (unsigned Elapsed) {switch (m_ICURSTATE) {case E_STATE00: DOSTATE00 (); Break; Case E_STATE01: DOSTATE01 (); Break; Default: Break;} void dostate00 (); void dostate01 (); void dostate01 ();} protected: int m_ICURSTATE;} a better implementation method generating state is a mapping function doState This facilitates maintenance of the code is higher efficiency improvements: template