|
The parameters that we have seen so far are called call-by-value parameters. That just means that, when an expression is passed to a function, the value of the expression is passed. For example, when
int k = 4; int j = sqr(2*k + 3);is evaluated, expression 2*k+3 is computed and its value, 11, is passed to function sqr.
The standards for this course require that a function body not change the value of any call-by-value parameter. For example, do not define a function like the following.
int f(int n) { … n++; … }Notice that f changes the value of n, which C++ allows but the standards for this course do not.
|