Go language pointer to a pointer
If a pointer variable to store the pointer is the address of another variable, called the pointer variable as a pointer to a pointer variable.
When you define a pointer to a pointer variable, a pointer to the first holding the second address pointer, the second pointer variable storage Address:
A pointer to a pointer variable declarations following format:
var ptr **int;
More than a pointer to a pointer to an integer variable.
Access pointer to a pointer variable value requires the use of two asterisk, as follows:
package main import "fmt" func main() { var a int var ptr *int var pptr **int a = 3000 /* 指针 ptr 地址 */ ptr = &a /* 指向指针 ptr 地址 */ pptr = &ptr /* 获取 pptr 的值 */ fmt.Printf("变量 a = %d\n", a ) fmt.Printf("指针变量 *ptr = %d\n", *ptr ) fmt.Printf("指向指针的指针变量 **pptr = %d\n", **pptr) }
Examples of the implementation of the above output is:
变量 a = 3000 指针变量 *ptr = 3000 指向指针的指针变量 **pptr = 3000