+ 1
explain what exactly a pointer do?
3 Respuestas
+ 1
A pointer contains the address of a variable at witch it points
And to declare a pointer use the *
Ex: int* p; a pointer for a int
Double*p; a pointer for a double
If you cout<<p ; it will give you the address in a hexadecimal number
If you want a pointer to point at a variable called a you do as follows
Int a;
Int *p;
p=&a
Where &a is the address of a in the memory
Now if you wanna print the value of a pointer you also use the * but in a diffrent syntax
Cout<<*p ;
It will give you the value of the variable
In this example it will give you the value of a ;
+ 1
a variable used to store an address of another variable...
- 2
it points to a variable , so if you change the value of a pointer , it will change the value of the varible it is pointing too