|
Original versus copies
as a default, when
you pass any object as an argument, the computer makes a copy of this
object so that your original is not used in the function.
This is called "passing by value"
if you like, you
can specify that you want the function to use the original
object.
This is called "passing by
reference"
to receive an argument passed
by reference, just precede the parameter name with "&" in the
function declaration.
- ex. void jumpjack(athlete
&someone) instead of
- void jumpjack(athlete
someone)
- no more changes are
needed.
example
|