c++ - 覆盖虚函数时的异常规范?

标签 c++

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

这是否必须至少具有限制性?正确的?还是其他人?

最佳答案

是的,它必须至少具有同样的限制性(§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.

关于c++ - 覆盖虚函数时的异常规范?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5295134/

相关文章:

c++ - 使用 std::enable_if<> 的模板特化

c++ - pthread 上的段错误

c++ - 如何使#include-file 的内容成为 cpp 文件中的编译时常量?

C++ 错误 : no match for 'operator>>' in 'input >> Group1->Entrepreneur::Item' |

c++ - 如何保证后声明的类的变量在前一个类中可见?

c++ - switch 语句多字符常量

c++ - 如何使 boost::apply_visitor 成为类访问者的友元函数?

c++ - 成员模板特化不使用 clang 编译

c++ - 如何最好地为 Visual Studio 2017 构建的 CMake C++ 项目设置输出目录?

c++ - OpenCV 投资返回率错误