class x is hidden by y

Denis Koroskin 2korden at gmail.com
Thu Oct 7 01:08:14 PDT 2010


On Thu, 07 Oct 2010 10:43:12 +0400, Benjamin Thaut  
<code at benjamin-thaut.de> wrote:

> For the following code in D 2.0 using dmd 2.049:
>
> import std.stdio;
>
> abstract class foo {
> protected:
> 	void WrongType(){
> 		assert(0,"Using wrong type");
> 	}
> public:
> 	void Update(int value){WrongType();}
>  	void Update(float value){WrongType();}
> }
>
> class blup : public foo {
> 	public override void Update(int value){
> 		writefln("%s",value);
> 	}
> }
>
> void main(string[] argv){
> 	foo s = new blup();
> 	s.Update(2);
> 	s.Update(2.5f);
> }
>
> When compiling with -w option I get the following warning:
> test.d(25): Error: class test.blup test.foo.Update(float value) is  
> hidden by blup
>
> When compiling without the -w option I get the following runtime error:
> core.exception.HiddenFuncError: Hidden method called for test.blup
>
> So I don't get why void Update(float value) is hidden. I come from C++ so
> please show me my mistake.
>
> Kind Regards
> Benjamin Thaut

That the case in C++, too. In C++ you would write using foo::Update.
In D, "alias foo.Update Update". It means, "bring base class' Update  
method to the current scope".


More information about the Digitalmars-d-learn mailing list