import std.stdio;

class A
{
        static int id = 0;
        this()
        {
                writeln("typeid=", typeid(this));
writeln("id=",typeof(this).id); //how to get runtime type of this ??
        }
}

class B : A
{
        static int id = 1;
}

class C : A
{
        static int id = 2;
}

void main()
{
        A a = new B;
        A b = new C;
}

typeof(this) can get compile time type while typeid yield a runtime TypeInfo instance, but how to get runtime type? I want the output to be "id=1" and "id=2" respectively.

Reply via email to