当整数除以零时,msvc 6会抛出什么? [英] What does msvc 6 throw when an integer divide by zero occurs?

查看:160
本文介绍了当整数除以零时,msvc 6会抛出什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在做一些实验,并且发现异常被抛出,当整数除以零时。

I have been doing a bit of experimenting, and have discovered that an exception is being thrown, when an integer divide by zero occurs.

#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。还有什么可以抛出的?

Clearly it is not throwing a std::exception. What else might it be throwing?

推荐答案

这是一个Windows结构化异常,与C ++无关,你会得到如果是C程序,则同样例外。

It's a Windows structured exception, which has nothing to do with C++ - you would get the same exception if it were a C program.

这篇关于当整数除以零时,msvc 6会抛出什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆