import std.stdio;

interface I
{
    void foo();
}

class C : I
{
    override void foo() { writeln("hi"); }
}

abstract class AC
{
    void foo();
}

class D : AC
{
    override void foo() { writeln("hi"); }
}

void main()
{
    auto c = new C();
    writeln(0);
    (cast(I)cast(void*)c).foo();
    writeln(1);
    (cast(C)cast(void*)c).foo();
    writeln(2);
    (cast(I)cast(C)cast(void*)c).foo();

    auto d = new D();
    writeln(3);
    (cast(AC)cast(void*)d).foo();
    writeln(4);
    (cast(D)cast(void*)d).foo();
    writeln(5);
    (cast(AC)cast(D)cast(void*)d).foo();
}

This produces the output:

0
1
hi
2
hi
3
hi
4
hi
5
hi

Why is there no "hi" between 0 and 1?

Reply via email to