摘要:
定义接口的类型,仅仅是方法的集合 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 type S struct{ i int } 8 9 func (p *S) Get() int { return p.i }10 11 func (p *S) Put(v int) { p.i = v }12 13 type R struct{ i int }14 15 func (p *R) Get() int { return p.i }16 17 func (p *R) Put(v int) { p.i = v }18 19 type I int 阅读全文
posted @ 2013-02-01 14:47
liubiaoren
阅读(137)
评论(0)
推荐(0)
摘要:
定义自己的类型type foo intstruct 1 package main 2 3 import "fmt" 4 5 type Skills []string 6 7 type Human struct { 8 name string 9 age int10 weight int11 }12 13 type Student struct {14 Human // 匿名字段,struct15 Skills // 匿名字段,自定义的类型string slice16 int // 内置类型作为匿名字... 阅读全文
posted @ 2013-02-01 11:24
liubiaoren
阅读(128)
评论(0)
推荐(0)
浙公网安备 33010602011771号