My understanding of pointers from the cplusplus documentation

http://www.cplusplus.com/doc/tutorial/pointers/

So this is how I learned to understand it:

& address-of operator (address of)

  • Dereference operator (value pointed to by)

myvar = 25;
foo = &myvar; // The value of foo is the address of myvar.
bar = myvar

baz = foo // baz equal to foo
baz = *foo // baz equal to the value pointed to by foo

A variable which stores the address of another variable is called a pointer.

So, with that said, according to the list above. foo = &myvar would mean that foo is equal to the address. Which in the case of the documentation it would be 1776. When reading baz = *foo, this means that baz is equal to the value pointed to by foo. So, baz would equal 25.

Do excuse me for the bullet point below the second line of the post. That is actually supposed to be an asterisk, but the website thought I was trying to bullet point.

Privacy & Terms