try-catch块在Devc ++上不起作用

时间:2013-08-02 17:43:07

标签: c++ try-catch

当我使用Devc ++或代码块(编译器:GNU)编译下面的代码时,它没有捕获异常,并且程序崩溃。请spmebody可以帮助我吗?提前谢谢。

#include <iostream>

using namespace std;

int main()
{
    int top = 90;
    int bottom = 0;
 try
     {
 cout << "top / 2 = " << (top/ 2) << endl;

cout << "top divided by bottom = ";
 cout << (top / bottom) << endl;

 cout << "top / 3 = " << (top/ 3) << endl;
 }
 catch(...)
 {
 cout << "something has gone wrong!" << endl;
 }

 cout << "Done." << endl;
 return 0;
    cout << "Hello world!" << endl;
    return 0;
}

0 个答案:

没有答案