www.digitalmars.com         C & C++   DMDScript  

D - Restrincting access modifiers on base classes.

The Java compiler will produce an error on the following file:

public class A
{
    public void doit() { }
}


class B extends A
{
    private void doit() { }
}

 javac A.java
A.java:16: doit() in B cannot override doit() in A; attempting to assign weaker access privileges; was public private void doit() { } ^ The equivalent code compiles just fine in DMD 0.82 but it seems wrong to me. "B" it's not an "A" anymore because it doesn't implement A's public interface from the perspective of other modules. Is this by design? Haven't been able to find any compeling reason. Thanks -- Julio César Carrascal Urquijo.
Apr 16 2004