Shadowing of members
H. S. Teoh
hsteoh at quickfur.ath.cx
Wed Jan 9 14:10:19 PST 2013
On Wed, Jan 09, 2013 at 10:59:21PM +0100, comco wrote:
> On Wednesday, 9 January 2013 at 21:30:32 UTC, H. S. Teoh wrote:
> >Because I forgot to declare 'a', I end up overwriting a base class
> >member which I didn't intend to change. Not good. (Furthermore, if
> >the class hierarchy is big, I may not find out about this until much
> >later -- I may not even be aware that some superclass declares 'a'.)
[...]
> At least this will be consistent behaviour. If it is an error, then
> a perfectly fine code now will stop compiling after someone (evil
> person!) adds a protected member 'i' to one of the super-super-super
> classes. Now not only my loop will stop to compile, but the
> inheritance will have the nice side effect of not allowing to use i
> for iteration in __any__ method.
> Of course, this is an extreme example, but valid.
Hmm, you're right. I withdraw my argument. :-P
T
--
I am not young enough to know everything. -- Oscar Wilde
More information about the Digitalmars-d
mailing list