Package and virtual functions

Timon Gehr timon.gehr at gmx.ch
Wed Jun 13 16:39:55 PDT 2012


On 06/14/2012 01:34 AM, BLM768 wrote:
>
>>
>> override will eventually be required when overriding a function. It is
>> already
>> if you compile with -w but not yet all of the time - though since
>> protected
>> isn't virtual and isn't really overriding anything, the compiler doesn't
>> complain if you don't use override with it (though it will if you do,
>> since
>> it's not overriding anything). So, eventually (or now if you use -w),
>> you will
>> _always_ know whether a function is overiding another or not, because
>> it will
>> have to have override if it is and can't have it if it isn't.
>>
>> - Jonathan M Davis
>
> That's good to know. I'll start using -w from now on.
> However, the problem still exists that if a function is meant to
> override a virtual method, but the method is not actually virtual, and
> the programmer forgets to type "override," the compiler won't complain
> and the error will slip through.
>
>

True, but it will be explicit in the derived class code:
No 'override', no function that is overridden.


More information about the Digitalmars-d-learn mailing list