Go语言中文网 为您找到相关结果 1

golang继承与多态的一个例子

package main //继承 import ( "fmt" ) //人类接口 type Human interface{ OneDay() Work() *Remuneration } //报酬 type Remuneration struct{ //钱 Money int //食物 Food string //爵位 Title string } //人类 type People struct{ } func (s *People) Eat(){ println("people eat foot") } func (s *People) Drink(){ println("people drink water") } ////某一天的活动,继承人类接口 //func (s *Peopl...阅读全文

博文 2018-07-13 18:18:34 yanglikai