Lab 8: Experiment 3

Identical Names for Corresponding Arguments and Value Parameters

The Issue: If a value parameter has the same name as its corresponding argument, will altering the parameter alter the corresponding argument?

Hypothesis: You try this one:

Question #8.3.1: Formulate a hypothesis that we want to test.

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;

This function is already called in the main program with the statement:

    change(arg1, arg2, arg3);
If giving parameters the same names as their arguments is a problem, compiling params.cpp will produce errors. If the names matter, then we might see a change in the values in the main program.

Observation: Compile and execute your program.

Question #8.3.2: Were you able to compile your program?

Question #8.3.3: If not, what error message did you get? If you could compile, what did the program output when you executed it?


Question #8.3.4: Is your hypothesis correct? How do you know? If it's not correct, what should it be?

Undo your modifications and then continue.

Back to the Lab Exercise  |  Forward to the Next Experiment

Report errors to Larry Nyhoff (