C++ Logo

std-proposals

Advanced search

Re: Specific Override Specifier

From: Ville Voutilainen <ville.voutilainen_at_[hidden]>
Date: Wed, 18 Mar 2020 19:34:10 +0200
On Wed, 18 Mar 2020 at 19:16, Ryan Nicholl via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
> A non-virtual function can override a virtual function, and vise versa. So virtual can't be deduced.

In either of those cases the functions you say are overriding are not
overriding. The point was that if you
have, hypothetically,

struct X : Y
{
    void Y::f() {...}
};

then we know that X::f is an override, so it doesn't need to be marked
as such, nor does it need to be marked
as virtual, because override, or its replacement syntax here, implies it.

Non-virtuals cannot override virtuals. That's hiding. Same goes for
virtuals 'overriding' non-virtuals, that's also hiding.

Received on 2020-03-18 12:37:10