引用传递
func main() {
var salary[5] int
salary[0] =7000
salary[1] =11000
salary[2] =17000
salary[3] =23000
salary[4] =33000
change(&salary)
for k,v:= range salary{
fmt.Printf("%d 对应 %d \n",k,v)
}
}
func change(salary*[5] int){
(*salary)[0] = 77000
fmt.Printf("朕的月收入 %d \n",salary[0])
}
值传递
func main() {
var salary[5] int
salary[0] =7000
salary[1] =11000
salary[2] =17000
salary[3] =23000
salary[4] =33000
change(salary)
for k,v:= range salary{
fmt.Printf("%d 对应 %d \n",k,v)
}
}
func change(salary[5] int){
salary[0] = 77000
fmt.Printf("朕的月收入 %d \n",salary[0])
}