覆盖虚函数时的异常规范? [英] Exception specification when overriding a virtual function?

查看:779
本文介绍了覆盖虚函数时的异常规范?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个类从另一个类继承并覆盖一个虚函数,那么派生(重写)函数的异常规范必须与基函数相关联。

If a class inherits from another and overrides a virtual function, how must the exception-specification for the derived (overridden) function be related to the base function?

这是必须至少是作为限制吗?对?

Is that is must be at least as restrictive? right? or others?

推荐答案

是的,它必须至少是同样限制的(§15.4/ 3):

Yes, it must be at least as restrictive (§15.4/3):


如果一个虚函数有一个异常规范,任何函数
的所有声明,包括定义,覆盖任何派生类中的虚函数,只允许由基类虚拟函数的
异常规范允许的异常。

If a virtual function has an exception-specification, all declarations, including the definition, of any function that overrides that virtual function in any derived class shall only allow exceptions that are allowed by the exception-specification of the base class virtual function.

这篇关于覆盖虚函数时的异常规范?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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