On Tuesday, 30 August 2016 at 02:43:16 UTC, Cherry wrote:

Can you help me with this code?

class InnerBase { int a = 1; }
class Outer {
    int b = 2;
    class Inner: InnerBase { int c = 3; }
}

void main() {
    Outer outer = new Outer;
    auto inner = outer.new Outer.Inner();
    foo(inner);
}

void foo (T) (T t) {
    import std.stdio : writeln;
    writeln(t.a);           // prints 1
    writeln(t.outer.b);     // prints 2
    writeln(t.c);           // prints 3
}

dmd v2.071.2-b2

This should be posted in Learn at http://forum.dlang.org/group/learn

Reply via email to