|
|
我按照一本C++入门书上写的例子编了一个很小的C++程序如下:
#include <iostream>
using namespace std;
int main() {
int top = 90, bottom = 0;
cout << "top / 3 = " << top / 3 << endl;
try {
cout << "top / bottom = " << top / bottom << endl;
}
catch(...) {
cout << "There has a exception!" << endl;
}
cout << "done!" << endl;
return 0;
}
按照书上写的,程序应该打印"There has a exception!" 消息,然后输出 "done!" 后退出的,但是在我的机器上执行到try{ }块内的语句时就直接报告说浮点数例外,然后程序就直接退出了,catch{}语句块根本就没有起作用.但是到windows下用VC试了一下这个程序,运行一切正常,我想程序应该是没有问题的,是不是debian里有哪个包没有安装造成的啊,还望高手指点!
我使用的是debian 4.0, g++4.1. |
|