I don't think there's a language feature for it, but you can implement this as a helper mixin:
Constructor Inheritance in D
-
04-07-2023 - |
Domanda
Is it possible to inherit constructors in D?
abstract class A {
this(int a) {
// ...
}
}
class B: A {}
void main() {
B b = new B(2); // Use A's constructor
}
I know I could just call A's constructor in B by doing super(param)
, but there'll be a lot of classes going on so I was wondering if there is a more automated way of doing it.
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow