类层次结构中的C ++异常处理 [英] C++ exception handling in class hierarchies

查看:129
本文介绍了类层次结构中的C ++异常处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在异常类层次结构中,catch语句的正确排序是什么,以便允许异常类的层次结构中的多个类的异常被捕获?

In a hierarchy of exception classes, What is the correct ordering of catch statements so as to allow exceptions of more than one class from the hierarchy of exception classes to be caught?

最多是派生到基础还是最基础的派生?

Is it most derived to the base or the base to most derived?

推荐答案

处理程序按出现的顺序进行匹配,因此您最想使用最具体的字符。

Most derived first. Handlers are matched in the order they appear, so you want the most specific ones first.

这篇关于类层次结构中的C ++异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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