What Does "Dereferencing" a Pointer Mean?
Please Include an Example with the Explanation. 7 6 Answers Reviewing the Basic Terminology It's Usually Good Enough - Unless You're Programming Assembly - to...
Please include an example with the explanation.
6 Answers
Must Read
Reviewing the basic terminology
It's usually good enough - unless you're programming assembly - to envisage a pointer containing a numeric memory address, with 1 referring to the second byte in the process's memory, 2 the third, 3 the fourth and so on....
- What happened to 0 and the first byte? Well, we'll get to that later - see null pointers below.
- For a more accurate definition of what pointers store, and how memory and addresses relate, see "More about memory addresses, and why you probably don't need to know" at the end of this answer.
When you want to access the data/value in the memory that the pointer points to - the contents of the address with that numerical index - then you dereference the pointer.
Different computer languages have different notations to tell the compiler or interpreter that you're now interested in the pointed-to object's (current) value - I focus below on C and C++.