I have tried to Google dereferencing, but I did not really find a specifically good and clear explanation. So can anyone please describe what it is? I know what it does and I am using it quite often, but I am not sure how I should explain in a formally correct manner.
Update: I have been told that I can't really get both formally correct and a good and clear explanation, since they apparently do not stick together; So I'll go with a formally correct explanation :) Regarding the possible duplicate, the answer to what dereferencing is in itself does not really seem that clear to me.
答案 0 :(得分:2)
If, without loss of generality1, a = &b
, then dereferencing a
, using *a
, yields b
.
1Assuming that =
, &
, and *
have not been overloaded for your types.
答案 1 :(得分:0)
Dereferencing a pointer means using the * operator (asterisk character) to access the value stored at a pointer: NOTE: The value stored at the address of the pointer must be a value OF THE SAME TYPE as the type of variable the pointer "points" to, but there is no guarantee this is the case unless the pointer was set correctly. The type of variable the pointer points to is the type less the outermost asterisk.
int n1;
n1 = (*p1);