1234567891011121314151617181920212223242526272829 |
- package model
- import "fmt"
- //多态
- type Live interface {
- run()
- }
- type People struct {
- name string
- }
- type Animal struct {
- name string
- }
- func (p *People) run() {
- fmt.Printf("%v在跑步", p.name)
- }
- func (a *Animal) run() {
- fmt.Printf("%v在跑步", a.name)
- }
- func allrun(live Live) {
- live.run()
- }
|