+ 1
What's the difference between *q=&p and **q=&p? Why is there 2 asterisks?
C++
4 Answers
+ 4
EDIT: pls see also Bennett Post comment about multiple '&'s
*q means the contents of memory address stored in q
**q means the contents of memory address stored in the contents of memory address q.
Two asterisks mean the variable is a pointer to a pointer. It contains an address which contains another address.
&p means the address which contains p.
So:
*q=&p means the contents of address pointed by q receives the address which contains p. It's the same as **q=p or q=&&p.
**q=&p means the contents of address pointed by the contents of address pointed by q receives the address which contains p. It's the same as ***q=p or q=&&&p. I doubt there's any use for this.
+ 1
But it makes a great party game.
0
Emerson Prado thank you sooo muchh... it's way clearer nowđ ...but how is it usually used?
0
HonFu the more asterisks the greater the partyđđđ