C++ Logo

std-discussion

Advanced search

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

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Tue, 17 Aug 2021 21:18:55 +0300
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?
 
With best regards
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
 
  
>Вторник, 17 августа 2021, 20:32 +03:00 от Ville Voutilainen <ville.voutilainen_at_[hidden]>:

>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 13:19:06