package main
import "fmt"
type Person struct {
name string
age int
}
func (p Person) SetInfoValue() {
fmt.Printf("SetInfoValue:%p,%v\n", &p, p)
}
func (p *Person) setInfoPointer() {
fmt.Printf("setInfoPointer:%p,%v\n", p, p)
}
func main() {
p := Person{"jack", 18}
(&p).setInfoPointer()
p.SetInfoValue()
funvT := p.SetInfoValue
funvT()
funvT2 := p.setInfoPointer
funvT2()
f := (Person).SetInfoValue
f(p)
f1 := (*Person).setInfoPointer
f1(&p)
}
转载于:https://my.oschina.net/lnmpstudy/blog/2052056