// 父类定义一个方法不去实现,让继承它的子类去实现,每一个子类有不同的表现多态属于继承
class Animal{
name:string
constructor(name:string){
this.name = name
}
eat(){
console.log('吃的方法')
}
}
class Dog extends Animal{
constructor(name:string){
super(name)
}
eat(){
return
this.name+'吃肉'
}
}
class Cat extends Animal{
constructor(name:string){
super(name)
}
eat(){
return
this.name+'吃粮食'
}
}