555: Mainline
Here, by way of summary, is where you are:
- You know that you ordinarily use call-by-value parameters. C++
programs always allocate a chunk of memory for each call-by-value parameter
and C++ programs always arrange for argument values to be copied into
that chunk. The rationale is that you want to isolate each function's
parameters from other parameters, local variables, and global variables
that happen to have the same name.
- You know that you generally use call-by-reference parameters when a
function's argument is to be an object that belongs to a subclass of the
parameter's type. The rationale is that all of the object, rather than
just the portion associated with the parameter's type, must be visible
inside the function. Each call-by-reference parameter shares an existing
memory chunk with a corresponding argument, rather than copying that
argument into a newly allocated chunk; hence, all data in the existing
memory chunk remains visible.