+ 1

what would be the difference using *pointer and &

if they both gonna point out to the adress in ram??

29th Dec 2016, 1:40 AM
Mike Batani
Mike Batani - avatar
3 Answers
+ 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.
29th Dec 2016, 3:36 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
There is NO DIFFERENCE b/w pointers and references
29th Dec 2016, 1:51 AM
Suvaditya
Suvaditya - avatar
+ 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 :)
29th Dec 2016, 6:43 AM
Slawomir Maciejewski