Saved Bookmarks
| 1. |
What are Golang pointers? |
|
Answer» Go Pointers are those variables that hold the address of any variables. Due to this, they are called SPECIAL variables. Pointers support two operators:
This is illustrated in the diagram below. Here, consider we have a variable x assigned to 100. We store x in the memory address 0x0201. Now, when we create a pointer of the name Y for the variable x, we assign the value as &x for storing the address of variable x. The pointer variable is stored in address 0x0208. Now to get the value stored in the address that is stored in the pointer, we can just write int Z:= *Y Pointers are used for the following purposes:
|
|