5 ms·
> Java calls references, works more like C/C++ pointer, rather than C++ reference What makes you say this? You can't do pointer arithmetic on Java references,
by ohf 8y ago
> Java calls references, works more like C/C++ pointer, rather than C++ reference
What makes you say this? You can't do pointer arithmetic on Java references, and the internal memory model is completely obscured. C++ and Java references look similar to and are accessed like variables. The major difference is that Java references can be reassigned, like a pointer, which is necessary in a language without true pointers.
- edflsafoiewq 8y agoIn C++, references aren't objects (eg. they have no size and no address), they can't be stored in a vector, there's no way to operate on the reference itself, everything is transparently forwarded to its referent, there is always a referent. In Java, a reference is a value, it can be stored in an ArrayList like a normal value, you can operate on the reference itself (reseating it, comparing two of them, comparing to null), there is not always a referent.
- ohf 8y agoTouche.