什么是“抛出”外面一个catch块呢? [英] what does "throw;" outside a catch block do?

查看:96
本文介绍了什么是“抛出”外面一个catch块呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是偶然发现这个代码:

I just stumbled this code:

void somefunction()
{
   throw;
}

我不知道:这是什么意思?

and I wonder: what does it mean?

我将问题标记为C ++和Visual C ++,因为我不知道答案。答案可能是与标准或一个特殊的Visual C ++扩展或Visual C ++忽略标准相关。

I tagged the question as C++ and Visual C++ because I did not know the answer. The answer could have been related to the standard or to a special Visual C++ extension or to Visual C++ ignoring the standard. That's why I thought both tags are justified.

推荐答案

当然,可能 somefunction / code>只是从一些 catch 块中调用(猜测,这可能是意图)。

Of course, it's possible that somefunction() is only ever called from inside some catch block (at a guess, that's probably the intent anyway).

如果 throw; 在异常不活动时执行,则调用 terminate() 15.1 / 8)。

If throw; is executed when an exception is not active, it calls terminate() (§15.1/8).

这篇关于什么是“抛出”外面一个catch块呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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