Exception 当整数被零除时,msvc 6抛出什么?
我做了一些实验,发现当一个整数被零除时,会抛出一个异常Exception 当整数被零除时,msvc 6抛出什么?,exception,visual-c++-6,Exception,Visual C++ 6,我做了一些实验,发现当一个整数被零除时,会抛出一个异常 #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
#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;
int main
(
无效的
)
{
尝试
{
int x=3;
int y=0;
intz=x/y;
CUT< P>这是一个Windows结构的异常,与C++无关,如果C程序是相同的异常,则 < P>这是一个Windows结构的异常,与C++无关,如果C程序也会得到同样的异常。 < P>结果未定义,可以用块来捕获错误。(结构化异常处理)。但是,为什么不在除法之前检查错误?如果结果未定义,您可以使用块捕获错误(结构化异常处理)。但是,为什么不在除法之前检查错误?在msvc6中,您可以使用catch(…)捕获错误并使用throw重新调用它;但是,由于您无法以这种方式检测异常类型,因此最好执行其他操作。在msvc6中,您可以使用catch(…)捕获它但是,如果不能用这种方法检测异常类型,那么最好做其他事情。 < P>。本文声称有一种使用函数将结构化异常转换为C++异常的方法。
< P>本文要求使用函数./P>有一种方法将结构化异常转换成C++异常。
它不会抛出被零除的异常吗?它不会抛出被零除的异常吗?