what is dereferencing?

What does dereferencing means?


does it mean rereferencing hte pointer to point to a certain address you want it to? or what
Dereferencing gets you a reference to the actual object the pointer is pointing to.
let say abc is a pointer...
when you use abc without asterix then you use address to which abc is pointing,

and when you use *abc with asterix then you use the value which is stored at the address where pointer is pointing to.

so DEREFERENCING is using a pointer with asterix. (USING A VALUE)
and REFERENCING is usning it withlut asterix. (USING ADDRESS)

but you should also know that pointer it self has an adress as well, but in fact on his address is stored the address of object where he is pointing to.

in your example *(abc)... this one is used in combination with other operators whic have higher priority then asterix. for example:

char*(abc) [10] = new char [10]
is not same as
char *abc [10] = new char [10] //ERROR

in first example you have declared dynamic array and in second exam. pointer to array.
so [] have higher priority than *
that's why u use ()
hope this help.
Last edited on
A pointer is a variable that tells the computer *where* a variable is stored.

Dereferencing a pointer tells the computer *what* is in the spot where a pointer is pointing to.
thanks alot. this forum has been a great help
Topic archived. No new replies allowed.