package main
import . "fmt"
/*面向对象 字段和方法的继承 */
type Animal struct {
color string
}
type Cat struct {
Animal
age int
}
func (animal Animal) Eat() {
Println("-----Eat----方法首字母大写就是公有的(public),小写就是私有的(private)---------", animal)
}
func (animal Animal) drink() {
Println("-----drink----方法首字母大写就是公有的(public),小写就是私有的(private)---------", animal)
}
func (cat Cat) Eat() {
Println("----对方法进行重写-Eat----方法首字母大写就是公有的(public),小写就是私有的(private)---------", cat)
}
func main() {
a := Cat{Animal{"black"}, 3}
a.drink()
a.Eat()
}