C++ FunctionsLesson 26Free preview
C++ Function Parameters
This lesson is part of C++ · All levels
Summary
This lesson explains how to pass data to functions through parameters and arguments. The parameter is the receiver on the declaration side, whereas the argument is the actual value sent at the call. You also learn the pass by value and pass by reference pattern, including giving the default value to the parameter.
Key points
- Parameters are written on declarations, arguments are written when functions are called.
- Pass by value copies data, so changes in the function do not change the original data.
- Pass by reference (&) allows the function to change the caller's variable.
- The parameter can be given a default value so that the argument can be left empty.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.