【发布时间】:2014-05-29 23:35:37
【问题描述】:
是否可以在 D 中继承构造函数?
abstract class A {
this(int a) {
// ...
}
}
class B: A {}
void main() {
B b = new B(2); // Use A's constructor
}
我知道我可以通过 super(param) 在 B 中调用 A 的构造函数,但是会有很多类在进行,所以我想知道是否有更自动化的方法来做这件事。
【问题讨论】:
标签: inheritance constructor polymorphism d