标签:实现 col call color phone fun inter hone div
把所有的具有共性的方法定义在一起,任何其他类型只要实现了这些方法就是实现了这个接口。
package main import "fmt" type Phone interface { call() } type NokiaPhone struct { } func (nokia NokiaPhone) call() { fmt.Println("I am Nokia") } func main() { var phone Phone phone = new(NokiaPhone) phone.call() }
标签:实现 col call color phone fun inter hone div
原文地址:https://www.cnblogs.com/liufei1983/p/9194832.html