package main
import"fmt"
type Animal interface{
eat()
}
type Live interface{
work()
}
type Dog struct{
name string
}
type People struct{
age int
}
func(dogDog)eat() {
fmt.Println(dog.name)
}
func(pPeople)work() {
fmt.Println(p.age)
}
type Family struct{
Dog
People
}
func main() {
f := Family{}
f.eat()
f.work()
}
Family 自动拥有 Dog , People 的所有方法