Hidden get method for properties

Lars Ivar Igesund larsivar at igesund.net
Wed Jul 19 05:09:06 PDT 2006


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;



More information about the Digitalmars-d-learn mailing list