+ 1

What's the difference between *q=&p and **q=&p? Why is there 2 asterisks?

C++

2nd Dec 2018, 11:18 PM
Ameerah
Ameerah - avatar
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.
3rd Dec 2018, 12:13 AM
Emerson Prado
Emerson Prado - avatar
+ 1
But it makes a great party game.
3rd Dec 2018, 12:21 AM
HonFu
HonFu - avatar
0
Emerson Prado thank you sooo muchh... it's way clearer now😄 ...but how is it usually used?
3rd Dec 2018, 12:23 AM
Ameerah
Ameerah - avatar
0
HonFu the more asterisks the greater the party🎊🎉😂
3rd Dec 2018, 12:24 AM
Ameerah
Ameerah - avatar