【发布时间】:2009-12-15 19:58:28
【问题描述】:
我一直在做一些实验,并发现当整数除以零时会引发异常。
#include <iostream>
#include <stdexcept>
using namespace std;
int main
(
void
)
{
try
{
int x = 3;
int y = 0;
int z = x / y;
cout << "Didn't throw or signal" << endl;
}
catch (std::exception &e)
{
cout << "Caught exception " << e.what() << endl;
}
return 0;
}
显然它没有抛出 std::exception。它还能扔什么?
【问题讨论】:
-
不会抛出被零除异常?