(资料图片)
golang中的多态是通过interface类型实现的
type Person interface { //接口Person规定了方法GetName GetName()}type Student struct { Name string Age int}func (this *Student) GetName() { ()}type Teacher struct { Name string Age int}func (this *Teacher) GetName() { ()}
关键词:
Copyright 2015-2022 北方地质网版权所有 备案号:京ICP备2021034106号-50 联系邮箱: 55 16 53 8@qq.com