欢迎光临散文网 会员登陆 & 注册

博学谷狂野大数据六期23年7月 学习笔记

2023-08-24 18:15 作者:bili_67158895267  | 我要投稿

golang中的多态是通过interface类型实现的

type Person interface {  //接口Person规定了方法GetName    GetName()}type Student struct {    Name string    Age  int}func (this *Student) GetName() {    fmt.Println(this.Name)}type Teacher struct {    Name string    Age  int}func (this *Teacher) GetName() {    fmt.Println(this.Name)}


博学谷狂野大数据六期23年7月 学习笔记的评论 (共 条)

分享到微博请遵守国家法律