previous | start | next

## Reference Parameters (Syntax 5.5 : Constant Reference Parameters)

Syntax 5.5 : Constant Reference Parameters
    const type_name& parameter_name
Example: |
    const Employee& e
Purpose: | Define a parameter that is bound to a variable in the function call, to avoid the cost of copying the variable into the parameter variable.

- Reference parameters are more efficient than value parameters because they do not make copies of the parameters.
- Passing variables by constant reference improves performance, but prevents the function from changing the value of the parameter.
- Objects make good constant reference parameters because they tend to have several attributes that need to be copied. Passing numbers by constant reference is generally not worth the effort.

previous | start | next