forbid field name conflict in class hierarchy
spir
denis.spir at gmail.com
Mon Nov 15 02:17:51 PST 2010
On Sun, 14 Nov 2010 16:25:56 -0800
Jonathan M Davis <jmdavisProg at gmx.com> wrote:
> On Sunday 14 November 2010 11:29:55 spir wrote:
> > I don't understand in which case you need to reuse the same name in a
> > subclass for a _different_ field -- whether the field is public or private
> > does not seem really relevant to me. But maybe I overlook some common use
> > case.
>
> Private fields are effectively hidden from derived classes. Derived classes
> shouldn't care what they're named and shouldn't have to care. The only time that
> it becomes any kind of issue is if both the base class and derived class are in
> the same module, since then the derived class has access to the base class'
> private members and functions (even though it probably shouldn't actually use
> them) from being in the same module.
>
> Having public fields shadow each other is problematic. Having private fields do so
> should be irrelevant.
>
> - Jonathan M Davis
Right, this makes sense.
Denis
-- -- -- -- -- -- --
vit esse estrany ☣
spir.wikidot.com
More information about the Digitalmars-d
mailing list