自己学习的,下面代码m转到p出错了,m2却可以。。这语言有点难
package main
import "fmt"
type People interface {
say()
}
type Men struct {
name string
}
func (men *Men) say() {
fmt.Println("mem say hi:", men.name);
}
func main() {
m := Men{"mike"}
m.say()
m2 := new(Men)
m2.name = "new men"
var p People
p = m2
p = m //error cannot use m (type Men) as type People in assignment:
p.say()
}
更多评论