The Issue: If a function alters the value of one of its reference parameters, what affect will that have on the corresponding argument?
Hypothesis: Changing the value of a reference parameter will not affect the value of the corresponding argument.
The Experiment: We can test the hypothesis by making two of
the parameters in change()
a reference parameter. Such a
change must be made in both the prototype:
void change(int & param1, int param2, int & param3);and in the definition:
void change(int & param1, int param2, int & param3) { param1 = 1; param2 = 2; param3 = 3; }
Observation: Compile and execute your program.
Question #8.5.1: What is displayed by the program?
Conclusions:
Question #8.5.2: Is our hypothesis correct? How do you know? If it's not correct, what should it be?
Don't change your code back until the next experiment.