Go继承的方法重写,继承抽象类实现
go的接口和继承就没什么好说的了,基本上大家都知道怎么玩,这里说下可能会困扰大家的问题。在Java里方法的重写和抽象类是很好用的,对于抽象和尽量共用抽象出来的代码很重要,但是用go很多人又不知道该怎么写才好,所以这里说下在go里怎么实现
方法重写
func main() {
m := &Man{
}
m.Eat()
m.Run()
m.Sleep()
}
type Person struct {
}
func (this *Person) Eat() {
fmt.Println("Person Eat")
}
func (this *Person) Run()