Go复习--field指针

type student struct {
    name string
    id int
}

func main() {
    stu := student{"wjc",11}
    test(&stu.id)
    fmt.Println(stu)

}

func test(id *int)  {
    *id++
}

指针也可以用于struct的field。

猜你喜欢

转载自www.cnblogs.com/wanjch/p/11517882.html