24D. Summary

C++ provides two physical parameter passing modes:

  1. call-by-value and
  2. call-by-reference.

A third mode, call-by-pointer, is a special case of call-by-value where the parameter is a pointer.

Logical parameter passing modes are:

  1. in-parameters (information passed from the caller to the callee),
  2. out-parameters (variables that are used to pass information from the callee to the caller) and
  3. in-out-parameters (used to pass information both directions.

When you are thinking about parameter passing, identify the logical mode that you need. Then use a suitable physical mode. Call-by-value can only be used for in-parameters, but it allows the actual argument to be any expression. Call-by-reference and call-by-pointer can be used for out-parameters and in-out-parameters, since the parameter must be a variable (or a pointer to a variable).