Hidden get method for properties

sclytrack at pi.be sclytrack at pi.be
Wed Jul 19 04:17:15 PDT 2006


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




import std.stdio;


class BaseClass
{
protected:
int _number;
public:
int number()
{
return _number;
}

int backupNumber()
{
return _number;
}
}

class BaseDerived:BaseClass
{
public:
void number(int value)
{
_number = value + 1;
}
}


int main()
{
BaseDerived derived = new BaseDerived();
derived.number = 10;
writefln( derived.number );	//Error 

//main.d(35): function main.BaseDerived.number (int) does not match argument
types ()
//main.d(35): Error: expected 1 arguments, not 0
//main.d(35): voids have no value

return 0;
}

One day, I will have a real girlfriend.



More information about the Digitalmars-d-learn mailing list