Next: References
Up: Functions
Back: Functions
-
Normally, a function cannot change a parameter's value
-
When your program's pass parameters to functions, C++
places a copy of the parameter's value in a temporary storage called
the stack;
any changes the function makes to the parameter effect only the copy
of the value
that resides on the stack
-
To change a parameter's value, a function must have knowledge of the
variable's
address
-
Using C++ address operator (&), your programs can pass
a variable's address to a function
-
When a function receives a variable's address, the function must
declare the parameter variables as pointers (by preceding the
variable names
with a *)
-
When the function wants to use the value pointed to by the pointer,
the function must precede the pointer variable's name with a *