Inherited constructor

Jerry labuurii at gmail.com
Fri Jul 25 17:54:51 UTC 2025


Another way to forward any constructor call is to do this:

import std.stdio;

class A {
   int x;
   this(int x) {
     this.x = x;
   }
}

class B : A {
   this(Args...)(Args args) {
     super(args);
   }
}

void main() {
   auto b = new B(42);
   b.x.writeln;
}


More information about the Digitalmars-d-learn mailing list