C++ Notes: Parameters

Formal Parameters

Formal parameters are written in the function prototype and function header of the definition. The formal parameters are effectively the same as local variables which are assigned values by each call to the function.

Actual Parameters or Arguments

When a function is called, the values (expressions) that are passed in the call are called the arguments or actual parameters (both terms mean the same thing). At the time of the call each actual parameter is assigned to the corresponding formal parameter in the function definition.

Value Parameters

By default, argument values are simply copied to the formal parameter variables at the time of the call. This type of parameter passing is called pass-by-value. It is the only kind of parameter passing in Java and C. C++ also has pass-by-reference (see below).

Reference Parameters

If you need to assign a value to Reference parameters are designed to allow functions to change the value of actual parameter variables. See Reference Parameters.

Additional topics

This summary doesn't mention the less frequent features: eg, variable parameter lists, default parameter values, ....