#include "stdafx.h"#include <iostream>//#include <stdexcpt>#include <exception>#include <windows.h>//#include <except.h>using namespace std;
void throwInt() throw(int){
int a = 10;
__try{ a = a/0; } __except(::GetExceptionCode() == EXCEPTION_INT_DIVIDE_BY_ZERO ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { cout<<"dionivided 0 except"<<endl; throw a; } cout<<"can i out in throeInt"<<endl;//打印不出来}
void throwExp() throw(){
try{
cout<<"int a = 2"<<endl; int a = 3; //a = a/(a-3); 除零不是异常
cout<<"a = a/(a-3);"<<endl;
//throw exception("haa"); } catch(exception e){
cout<<e.what()<<endl;
throw exception("catch not deal"); }
cout<<" throw () exception"<<endl;//打印不出来
}int _tmain(int argc, _TCHAR* argv[]){ try {
throwExp(); //throwInt();
} catch(int e) { cout<<" i caught exception value is"<<e<<endl; } catch(exception e) { cout<<e.what()<<endl; } catch(...) { cout<<"i can do all thing "<<endl; }
cout<<"can i came out?"<<endl;//可以打印出来
return 0;}