Zebra0.com

cppFunctions with pass by reference

Functions with pass by reference

Learn C++ in step-by-step lessons.

Functions with pass by reference

Pass by reference means that instead of passing the value of a variable to a function, we pass the address of the variable as an argument. When a function receives the address of a variable it can change the value stored at that address.

Pass by reference is usually only used if we need to change the value of a variable.


Goals:

Objectives:

Please study the material at each of the links below.

  1. Addresses of variables Addresses of variables
  2. Finding half the value
  3. Finding half the value explicitly
  4. Arguments must match
  5. Exchanging two values
GlossaryGlossary for passbyref lesson
Full Glossary