+ 2
what is dereferencing ?
2 Réponses
+ 3
To access the value pointed by a pointer, you have to dereference it first with *.
int foo = 42;
int* p = &foo;
cout << *p << endl; //Here we dereference p and print the value pointed, 42.
+ 1
prateek nandwana, I think DEFERENCE means simply asterisk ( star ) (*) applying to variable. ( Creating a POINTER variable. )
For example.,
int sad; // is a variable.
/*
If i apply the asterisk to variable; that is "sad" it means i DEFERENCE the "sad" variable. In other words i create a pointer variable. */
*sad = NULL; // THIS IS A DEREFERENCING.
I Hope you will understand.🙏👍✔️