C++ Logo

std-discussion

Advanced search

Re: More than one final overrider of a virtual functions.

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Tue, 17 Aug 2021 20:32:07 +0300
On Tue, 17 Aug 2021 at 20:17, Vladimir Grigoriev via Std-Discussion
<std-discussion_at_[hidden]> wrote:
>
> In the paragraph #2 of the section «11.7.2 Virtual functions» if the C++ 20 Standard there is written
>
> «In a derived class, if a virtual member function of a base class subobject has more than one final overrider the program is ill-formed.»
>
> And there is an example
>
> [Example:
> struct A { virtual void f(); };
> struct B : A { };
> struct C : A { void f(); };
> struct D : B, C { }; // OK: A::f and C::f are the final overriders
> // for the B and C subobjects, respectively
>
> If I understand correctly should there the comment be appended that the code snippet is ill-formed because the class D has two final overriders of the functions f?

No, because the two final overriders are for member functions of
different base class subobjects. For each of those base
class subobjects, there is only one final overrider.

Received on 2021-08-17 12:32:20