+ 2

Please can anyone help me with the difference between a Reference and a Memory address. Thanks.

Difference between Reference and Memory Address

6th Nov 2018, 8:45 AM
Just_Chuel
2 Respostas
+ 2
I'm not qualified to answer this question, since the true nature of how a reference is implemented is complicated. I'll write what I know, maybe someone will correct me later. A reference is an alias (another name) for the variable it is initialized with. Think of it like a weird-looking, constant, funny pointer that points to a variable's memory address. The compiler often replaces a reference with the address of the variable it refers to when said reference is encountered. A reference is not a memory address, and also doesn't have an address of its own (which is different from a pointer).
6th Nov 2018, 9:45 AM
Hoàng Nguyễn Văn
Hoàng Nguyễn Văn - avatar
+ 1
Thanks for your explanation
7th Nov 2018, 1:30 AM
Just_Chuel