|
|
|
|
|
by TuringTest
1036 days ago
|
|
A reference, unlike a pointer, always points to the same memory address(*); so the reference is immutable even if the cell contents it points to are not. That's the difference between a reference and a pointer, by definition; not just the different syntax. Back in the day, that was one of the major selling points of the new language Java over the more common C and C++. Developers don't learn about it nowadays because changing pointers is practically never done outside the most esoteric parts of system programming. (*) Semantically, at least. The compiler is free to relocate the value to a different memory position in a way transparent to the programmer. |
|