The Question: If a value parameter has the same name as its corresponding argument, will altering it alter the corresponding argument?
Hypothesis: Review the value parameter definition, and then construct a hypothesis.
The Experiment:
Modify the definition of Change(), so that its
parameter-names match the argument names:
void Change(int arg1, int arg2, int arg3)
{
arg1 = 1;
arg2 = 2;
arg3 = 3;
}
(Hint: To make it easier to undo this modification,
use copy-and-paste to make a copy of the function with the original names;
surround one of the copies with a block comment, and modify the uncommented function.)
This function is called in the main program with the statement:
Change(arg1, arg2, arg3);so that if giving parameters the same names as their arguments is a problem, compiling params.cpp will produce errors.
Observation: Translate your source program. What is displayed ?
Conclusions: Review the definition of a value parameter,
and record your conclusions.
Undo your modifications and then continue.
Forward to the Next Experiment