CHAPTER7-12.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER7-12.cpp
- #pragma warning(disable:4786)
- #include <iostream>
- #include <string>
- #include <deque>
- #if _MSC_VER > 1020 // if VC++ version is > 4.2
- using namespace std; // std c++ libs implemented in std
- #endif
- #define OK 0
- #define INFO 1
- #define WARNING 2
- int main (void)
- {
- int return_code;
- deque<string> InfoMessages;
- deque<string> WarningMessages;
- InfoMessages.push_back("Info: Program started");
- WarningMessages.push_back("Warning: No Customer records have been found");
- return_code = OK;
- if (!InfoMessages.empty()) //判断容器是否为空
- { InfoMessages.push_back("Informational Messages:");
- return_code = INFO;
- }
- if (!WarningMessages.empty()) //判断容器是否为空
- { WarningMessages.push_back("Warning Messages:");
- return_code = WARNING;
- }
- if (InfoMessages.empty() && WarningMessages.empty()) //判断容器是否为空
- { cout << "There were no messages " << endl; }
- switch(return_code)
- {case 0:
- cout<<" Neither Informataion nor warning message"<<endl;
- break;
- case 1:
- cout<<InfoMessages[0]<<endl<<InfoMessages[1]<<endl;
- break;
- case 2:
- cout<<WarningMessages[1]<<endl<<WarningMessages[0]<<endl;
- break;
- }
- return return_code;
- }