Go language pointer knowledge point sharing

Go pointer

1. Definition
1. var pointer name * pointer type, eg:,var ptr *intdefine an integer pointer named ptr
2. Pointer type: pointer variable stores an address, and the space pointed to by this address is the value that
can be assigned to Pointer, eg:,var ptr *int =&numand then use to*ptrget the value of num

Second, the pointer precautions
& meanings of the symbols is a variable taking address, such as: the address of a variable is &a
*the symbol means address values
, such as: *&a, where a variable is a value of the address, of course, is a value of a
Simple Explanation : *and &can counteract each other, but not vice versa

Three, pointer related icons

var num int =1
var  i int = 999
var ptr *int=&i

as the picture shows
After reading, if it is helpful to yourself, please like and support, thank you

Guess you like

Origin blog.csdn.net/yyq1102394156/article/details/113871481