c++ - Pointers, References and the other one -
i'm learning references , pointers , variables. think i've gotten myself lost.
at high level, understanding
*pointer = "points" location in memory
&reference = references values
so, means
char* c; //pointer char& c; //reference char c; //does not have flash name? prefix? if pointer "location" (as per description above) , reference value, char c ? both? or value? tests indicate value only, if true, why use reference?
eg, why use
void myfunction(int& size); over
void myfunction(int size);
let me give variables unique names, easier talk them:
char = 'x'; char& b = a; char* c = &a; in example, a name fresh box code of character 'x' stored inside it:
+-----+ | 120 | +-----+ and b name same box:
+-----+ | 120 | b +-----+ finally, c name of box containing pointer first box:
+-----+ | 120 | b +-----+ ^ | +--|--+ c | | | +-----+
Comments
Post a Comment