struct ZeroError{
int err;
ZeroError(int e){err = e;}
};
int div(int a,int b)
{
if (b == 0)throw int(10);
return a/b;
}
int main()
{
try{
int x = div(10,0);
cout<< x;
}
catch(int z){
cout<<z;
}
}
即使當我跑我得到鐺不是C++異常正常工作
程序終止叫做拋出
此應用程序已請求「詮釋」的實例後,異常被捕獲運行時以終止它在 不尋常的方式。請聯繫應用程序的支持團隊獲取更多 信息。
看起來像是有例外關閉 – Nikko
鏘支持在Win32異常編譯的是不存在的,但。 http://cygwin.com/ml/cygwin/2012-02/msg00015.html – legends2k
你如何在叮噹中打開C++異常?例如,在msvc中,你使用'/ EHsc' – EhevuTov