2
如果派生類的構造函數簽名與基類不同,它是否會破壞oop原理(ex,Liskov原理)?派生類的不同構造函數簽名
class Base {
protected x: number;
protected y: number;
constructor(x: number, y: number) {
this.x = x;
this.y = y;
}
}
class Derived extends Base {
private text: string;
constructor(text: string, x: number, y: number) {
super(x, y);
this.text = text;
}
}