http://cooker.iteye.com/blog/849208
- #include <iostream>
- #include <sstream>
- enum MODULEID {
- MODULE_A,
- MODULE_B,
- MODULE_C ,
- MODULE_D,
- MODULE_E,
- MODULE_F,
- MODULE_NONE
- };
- void Init()
- {
- MODULEID eModuleId = MODULE_A;
- bool bStart = true;
- while(bStart)
- {
- switch(eModuleId)
- {
- case MODULE_A:
- std::cout<<"MODULE A is ok"<<std::endl;
- eModuleId = MODULE_B;
- continue;
- case MODULE_B:
- std::cout<<"MODULE B is ok"<<std::endl;
- eModuleId = MODULE_C;
- continue;
- case MODULE_C:
- std::cout<<"MODULE C is ok"<<std::endl;
- eModuleId = MODULE_D;
- continue;
- case MODULE_D:
- std::cout<<"MODULE D is ok"<<std::endl;
- eModuleId = MODULE_E;
- continue;
- case MODULE_E:
- std::cout<<"MODULE E is ok"<<std::endl;
- eModuleId = MODULE_F;
- continue;
- case MODULE_F:
- std::cout<<"MODULE F is ok"<<std::endl;
- eModuleId = MODULE_NONE;
- continue;
- default:
- std::cout<<"MODULE is fully completed"<<std::endl;
- bStart = false;
- }
- }
- }
- int main()
- {
- Init();
- return 0;
- }
result:
MODULE A is ok
MODULE B is ok
MODULE C is ok
MODULE D is ok
MODULE E is ok
MODULE F is ok
MODULE is fully completed