Why is this allowed? Inheritance variable shadowing

sighoya sighoya at gmail.com
Wed May 26 21:33:17 UTC 2021


On Wednesday, 26 May 2021 at 18:58:47 UTC, JN wrote:
> I am not buying the "C++ does it and it's legal there" argument.

A point for it is the consistency with methods which also 
redefine super methods as default strategy.
The question is if the default strategy needs to be changed?
I wouldn't argue so as overriding super methods/fields as default 
is much more dangerous as it might destroy the super class's 
semantics.

What about explicitly tagging fields with override instead, then 
it would be a compile error if the base class hasn't the tagged 
fields.



More information about the Digitalmars-d-learn mailing list