André Wagner <[email protected]> wrote:

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?

That would be because B.j hides A.j. A's constructor sets
B.super.j, not B.j.

If you try in your main, writeln( cast( A )( b ).j.x );, you
will see that A.j is set correctly.

--
Simen

Reply via email to