Re: pass by reference
- From: Andreas Leitgeb <avl@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: 04 Apr 2008 11:26:59 GMT
Chase Preuninger <chasepreuninger@xxxxxxxxx> wrote:
All objects are "passed by reference" and all primitive types have
their value copied.
The objects are indeed passed by reference.
There is a fundamental difference between C++ and Java
with respect to the assignment-operator.
In C++, assignment is the Object's business,
so, passing an object into a function and assigning
to it inside, will change the value of that object,
and thus be visible outside.
In Java, assignment (with "="-operator) does not
change the referenced Object, but replace it, by
changing only the reference.
This effect, however, is not visible outside,
because it's only the Object, but not the reference
itself, that is passed "by ref".
.
- Follow-Ups:
- Re: pass by reference
- From: Roedy Green
- Re: pass by reference
- From: Lew
- Re: pass by reference
- References:
- pass by reference
- From: angelochen960@xxxxxxxxx
- Re: pass by reference
- From: Chase Preuninger
- pass by reference
- Prev by Date: Re: Calculating PI with the law of Cosines (Wont Work)
- Next by Date: Re: pass by reference
- Previous by thread: Re: pass by reference
- Next by thread: Re: pass by reference
- Index(es):
Relevant Pages
|