Class field inheritance

André Wagner andre.nho at gmail.com
Wed Jun 30 13:25:25 PDT 2010


Ok, bad example :)

Here's a better example of what I wanted to ask:

class XA { uint x; }
class XB : XA { uint y; }

class A
{
    XA j;
    this(XA j) { this.j = j; }
}

class B : A
{
    XB j;
    this(XB j) { super(j); }
}

void main()
{
    XB j = new XB();
    j.x = 10;
    j.y = 20;
    B b = new B(j);
    writefln("%d\n", b.j.x);
}

Why doesn't this work?


More information about the Digitalmars-d mailing list