地址copy,引用copy
func addressCopy() {
i := 7
j := &i
i = 10
fmt.Println(i, *j)//10 10
}
值copy
func valueCopy() {
i := 7
j := i
i = 10
fmt.Println(i, j)//10 7
}
地址copy,引用copy
func addressCopy() {
i := 7
j := &i
i = 10
fmt.Println(i, *j)//10 10
}
值copy
func valueCopy() {
i := 7
j := i
i = 10
fmt.Println(i, j)//10 7
}
本文标题:golang 值和指针
本文链接:https://www.haomeiwen.com/subject/jevppftx.html
网友评论