【发布时间】:2020-05-08 20:14:37
【问题描述】:
我正在使用 dart 编程语言,其中我有一个抽象类 Vehicle 和一个子类 car
abstract class Vehicle {
int _tires;
String _type;
Vehicle(int tires,String type) {
this._tires=tires;
this._type=type;
}
}
class car extends Vehicle {
car (int tires, String type) {
this._type=type;
this._tires=tires;
}
}
Vehicle 和 car 都在同一个库中,但我不断收到错误提示
超类“Vehicle”没有零参数构造函数。尝试在“Vehicle”中声明一个零参数构造函数,或在“Vehicle”中显式调用不同的构造函数。
为什么我不能在汽车子类中声明一个单独的构造函数?提前致谢!
【问题讨论】:
标签: oop dart constructor