dup field in sub-class should be reported by the compiler
sa
someanon at yahoo.com
Mon Aug 13 15:16:25 PDT 2007
> Exactly what problem does this solve? If you're writing a derived class,
> and you create another field of the same name as a field in the base
> class, what bug has been created? The base class functions will still
> use the base class field, the derived class functions will still use the
> derived class field. The fields aren't polymorphic, so no hijacking can
> happen.
> I just don't see the issue.
It's less a problem if the programmer is *aware* of the re-definition; but in
practice, most the time, the programmer just forget, and will *assume* there's
only one definition, then it will cause strange error in his eye.
Now, even from an OO modelling point of view:
Dog {
Tail tail;
}
MyDog {
Tail tail;
}
Why should MyDog have a tail which is already defined in Dog?
It burden the programmer's thoughts, instead of simplify it.
More information about the Digitalmars-d
mailing list