+ 1
what would be the difference using *pointer and &
if they both gonna point out to the adress in ram??
3 Respostas
+ 8
* is the 'point to' operator. It tells the program you want to point to something (most of the times, an address).
& is the 'address-of' operator. It tells the program to return the address of anything which comes after it.
E.g.
int *p;
int q = 39;
p = &q;
// now, p stores the address of q.
cout << *p;
// this tells the program to print which is pointed by p.
// outputs 39.
+ 1
There is NO DIFFERENCE b/w pointers and references
+ 1
'&' gets a pointer 'p' address memory cells where it is stored variable 'x'.
'*' gets a pointer 'p' the contents of memory from the address which is stored in the variable 'x'.
Hatsy Rei is right :)