Is this a D puzzler or a bug?

Bradley Smith digitalmars-com at baysmith.com
Fri Mar 30 13:40:59 PDT 2007


What is wrong with the following code?

class A {
   protected void method() {}
}

class B : public A {
   protected void method() {
     A.method();
   }
}

Answer:

If A and B are defined in the same module, A is able to access the 
non-static protected method of its superclass using a static method call.

However, if A and B are defined in different modules, the error "class 
a.A member method is not accessible" occurs.

Is this a bug? (I don't know. I am really asking.)


Current solution:

Replacing "A.method()" with "super.method()" corrects the problem.



More information about the Digitalmars-d-learn mailing list