4 ms·
https://en.wikipedia.org/wiki/Reference_(C%2B%2B) https://en.wikipedia.org/wiki/Reference_(C%2B%2B) https://courses.washington.edu/css342/zander/css332/passby.
by jack9 8y ago
https://en.wikipedia.org/wiki/Reference_(C%2B%2B) https://en.wikipedia.org/wiki/Reference_(C%2B%2B)
https://courses.washington.edu/css342/zander/css332/passby.html https://courses.washington.edu/css342/zander/css332/passby.h...
I mean, it's not hard to take a look at what was already decided.
- asfasgasg 8y ago> In pass by reference (also called pass by address), a copy of the address of the actual parameter is stored. Use pass by reference when you are changing the parameter passed in by the client program. Your understanding of "what has already been decided" is contradicted by your second link. Under the definition there, Java is pass by reference except for primitives -- i.e. it is contra the "Java is Pass-by-Value" article. (I suppose you could say that "the actual parameter" is not the referent object, but the pointer to it in the frame of the caller function. But I'm not aware of any definition of "actual parameter" that would allow you to impose that interpretation on others -- it's a vague term. I'd further argue that that interpretation is pretty convoluted, which might be why few languages other than C++ use it. Anyway, "the actual parameter" could mean the referent or the pointer to the referent depending on how you're modeling the program.)
- colanderman 8y agoNo. If Java were pass-by-reference a function could cause the caller's reference to point to an entirely different object. That is, yes, the implementation must pass a pointer which points into the caller's frame. This is what happens with C++ references. This is not what happens with Java arguments.