有没有一种方法,当参数完全相同时,不必重复写
代码如下:
this(parent class args) {super(parent class args);}
?代码如下:
class Parent {
string name;
this(string name) {
this.name = name;
}
}
class Child : Parent {
}
unittest {
auto child = new Child("a name");
assert(child.name == "a name");
}
https://run.dlang.io/is/YnnezI
这个链接给我返回了编译错误:
Error: class onlineapp.Child cannot implicitly generate a default constructor when base class onlineapp.Parent is missing a default constructor