Reputation: 16865
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.
Upvotes: 2
Views: 197
Reputation: 25187
I don't think there's a language feature for it, but you can implement this as a helper mixin:
Upvotes: 2