2.34. Go language pointer to pointer

发布时间 :2023-10-12 23:00:09 UTC      

If a pointer variable holds the address of another pointer variable, the pointer variable is called a pointer variable that points to the pointer.

When defining a pointer variable that points to a pointer, the first pointerstores the address of the second pointer, and the second pointer stores theaddress of the variable:

Image0

The pointer variable declaration to the pointer is in the following format:

var ptr **int;

The pointer variable to the pointer above is an integer.

Accessing the value of a pointer variable pointing to a pointer requires theuse of two * number, as follows:

package main

import "fmt"

func main() {

   var a int
   var ptr *int
   var pptr **int

   a = 3000

   /* Pointer ptr address */
   ptr = &a

   /* Pointing to pointer ptr address */
   pptr = &ptr

   /* Obtain the value of pptr */
   fmt.Printf("Variable a= %d\n", a )
   fmt.Printf("Pointer variable * ptr = %d\n", *ptr )
   fmt.Printf("Pointer variable pointing to a pointer **pptr = %d\n", **pptr)
}

The output of the above example is as follows:

Variable a= 3000
pointer variable *ptr = 3000
Pointer variable pointing to a pointer **pptr = 3000

Principles, Technologies, and Methods of Geographic Information Systems  102

In recent years, Geographic Information Systems (GIS) have undergone rapid development in both theoretical and practical dimensions. GIS has been widely applied for modeling and decision-making support across various fields such as urban management, regional planning, and environmental remediation, establishing geographic information as a vital component of the information era. The introduction of the “Digital Earth” concept has further accelerated the advancement of GIS, which serves as its technical foundation. Concurrently, scholars have been dedicated to theoretical research in areas like spatial cognition, spatial data uncertainty, and the formalization of spatial relationships. This reflects the dual nature of GIS as both an applied technology and an academic discipline, with the two aspects forming a mutually reinforcing cycle of progress.