Exception specification when overriding a virtual function?

后端 未结 2 1049
轮回少年
轮回少年 2020-12-29 09:22

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

2条回答
  •  悲&欢浪女
    2020-12-29 09:27

    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.

提交回复
热议问题