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 21:29:52 +0300
On Tue, 17 Aug 2021 at 21:19, Vladimir Grigoriev <vlad.moscow_at_[hidden]> wrote:
>
> Well, If to change the declarations the following way
>
> struct A { virtual void f(); };
> struct B : virtual A { };
> struct C : virtual A { void f(); };
> struct D : B, C { }; // OK: A::f and C::f are the final overriders
> // for the B and C subobjects, respectively
>
> when in this case will the code snippet be ill-formed?

No, because now there's only one final overrider, in C. But you're on
the right track; this is ill-formed:

struct A { virtual void f() {} };
struct B : virtual A { void f() {}};
struct C : virtual A { void f() {} };
struct D : B, C { }; // error: no unique final overrider for 'virtual
void A::f()' in 'D'

Received on 2021-08-17 13:30:09