嵌套try ... catch里面C ++异常处理程序? [英] Nested try...catch inside C++ exception handler?

查看:151
本文介绍了嵌套try ... catch里面C ++异常处理程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的异常处理程序中执行的代码本身可能会抛出异常。

The code I want to execute in my exception handler may itself throw an exception.

下面的结构是合法的C ++?如果是,是否有任何缺点?

Is the follow structure legal C++? If yes, are there any downsides?

try
{
    // ...
}
catch (const E&)
{
    try
    {
        // ...
    }
    catch (const F&)
    {

    }
}


推荐答案

不,没有缺点。这是你应该这样做的方式。

No, there are no downsides. That's the way you should do it.

这篇关于嵌套try ... catch里面C ++异常处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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