Hidden get method for properties

sclytrack at pi.be sclytrack at pi.be
Wed Jul 19 05:43:09 PDT 2006


In article <e9l7d5$1g4j$1 at digitaldaemon.com>, Lars Ivar Igesund says...
>
>Hasan Aljudy wrote:
>
>> 
>> 
>> sclytrack at pi.be wrote:
>>> I've only been using D sinds June 2006, I stumbled accross this today.
>>> 
>>> 
>>> Is this normal D behavior that int number() is no longer accessible from
>>> the derived class while backupNumber still is?
>>> 
>>> I can work around this, without problems. :-)
>>> 
>>> dmd v0.163
>> 
>> It's got to do with function overloading in the derived class.
>> When you overload number in Derived, you lose visibility to the other
>> number method(s).
>> 
>> As for why is that? I don't know. Maybe to prevent possible confusion.
>
>It has to do with the overload rules in D, which are taken from C++. It
>turns out that the issues people find with this feature in D, isn't
>particularly present when using C++, so people are quite often confused
>with the current operation (which is quite opposite to how it works in
>Java).
>
>The solution in this case is to use alias to pull the symbol into the
>namespace of the subclass:
>
>alias BaseClass.number number;


Yeah, I found it a bit confusing. I'm sure Walter has a reason for designing it
this way, but is too busy to answer this.


Thanks for your reply, Sclytrack.





More information about the Digitalmars-d-learn mailing list