Private static inheritance

David Ferenczi raggae at ferenczi.net
Sun Sep 23 04:54:32 PDT 2007


I've come accross with the following:

test.d
-------------8<------------------

module test;

static private import testAA: AA;
static private import std.cstream: dout;

int main(char[][] args)
{
    dout.writeLine(AA.text);
    return 0;
}

-------------8<------------------



testA.d
-------------8<------------------

module testA;

class A
{
private:
    static const char[] text = "text";
}

-------------8<------------------



testAA.d
-------------8<------------------

module testAA;

static private import testA: A;

class AA : A
{
}

-------------8<------------------


Running the program the output is: "text"


I don't know what would be the correct behaviour, but I presume that a 
private member (even if it's static) can't be accessed either from outside,
neither from a subclass. Am I wrong?

Regards,
David








More information about the Digitalmars-d-learn mailing list