|
C++ provides two physical parameter passing modes:
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:
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).
|