[Issue 2563] New: Derived class is implicitly castable to Base class when inherited privately

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 7 12:02:18 PST 2009


http://d.puremagic.com/issues/show_bug.cgi?id=2563

           Summary: Derived class is implicitly castable to Base class when
                    inherited privately
           Product: D
           Version: 2.023
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: 2korden at gmail.com


module A;

class A1
{
    void foo();
}

class A2 : private A1
{
}

module B;

void main() {
    A2 a2 = new A2();
    // a2.foo(); // Error: class A.A2 member foo is not accessible

    A1 a1 = a2;  // This line should yield an error
    a1.foo();    // ta-dam! Private method invoked
}


-- 



More information about the Digitalmars-d-bugs mailing list