How to get child class Type and members from parent class?

zoujiaqing zoujiaqing at gmail.com
Wed Nov 20 10:05:11 UTC 2019


import std.stdio;


class A
{
     this(T)(T t)
     {

     }

     void write()
     {
         T _this = cast(T) this;
         writeln(this.v);
     }
}

class B : A
{
     string v = "hello";
}

void main()
{
     auto b = new B;

     writeln(b.write()); // print hello
}


More information about the Digitalmars-d-learn mailing list