go方法重载
来源:互联网 发布:数据库安全测试工具 编辑:程序博客网 时间:2024/06/05 19:21
package mainimport "fmt"//about receiver functiontype Student struct { Human school string}type Employer struct { Human company string}type Human struct { name string age int phone string}//implement Human methodfunc (h *Human) SetName(name string) { fmt.Print("human") h.name = name}func (h *Human) SetAge(age int) { h.age = age}func (h *Human) SetPhone(phone string) { h.phone = phone}func (h *Human) GetInfo() Human { return *h}func (s *Student) SetName(name string) { fmt.Print("student") /*about here we can use two wanys to change the value ,so ,how different there ?????*/ s.name = name //s.Human.name = name}//在go中也有方法的重写和继承func main() { s := Student{} s.SetPhone("18755201184") s.SetName("tsong") s.SetAge(26) fmt.Print(s.GetInfo())}
0 0
- go方法重载
- go 方法
- 方法重载
- 重载方法
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 方法重载
- 安卓的通知组件
- commons-fileupload下载文件
- 一个textview里设置多种字体颜色,并添加图片
- c# 访问修饰符
- unity3d初学第一天
- go方法重载
- UITableView刷新小技巧
- jQuery的动画
- JAVA011--继承
- 【审核】检查iOS项目中是否使用了IDFA
- SAP 增强
- MySQL运算符使用问题
- 紫金桥组态软件分屏显示技术的应用
- IOS中 Block用法进阶三 关于存储变量和应用举例