-
- #include "stdafx.h"
-
- #include <iostream>
- using namespace std;
-
- #include <windows.h>
-
- std::string s;
-
-
- void myFinally()
- {
- int i=2;
-
-
-
-
-
-
- __try
- {
- s="My Finally";
-
- i = i/0;
- }
-
- __except( GetExceptionCode()==EXCEPTION_INT_DIVIDE_BY_ZERO ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH )
- {
- cout<<"got除零错误!"<<endl;
- }
- cout<<s.c_str()<<endl;
- }
-
- int _tmain(int argc, _TCHAR* argv[])
- {
- cout<<"main begin"<<endl;
-
- try{
- myFinally();
- }catch(std::string s)
- {
- cout<<"got其它错误"<<endl;
- }
-
- cout<<"main end"<<endl;
-
- return 0;
- }
http://blog.csdn.net/lee353086/article/details/6365998