package a type Animal interface { call() } type Dog struct { } type Cat struct { } func (dog Dog) call() { println("我是狗,狗叫") } func (cat Cat) call() { println("我是猫,猫叫") } func main() { println("hello") var animal Animal animal = new(Dog) animal.call() }
本文来自博客园,作者:狂躁的键盘,转载请注明原文链接:https://www.cnblogs.com/wangweiip/p/17118602.html