|
@@ -265,12 +265,12 @@ In the introduction to the topic of functions you saw that in mathematics and in
|
265
|
265
|
|
266
|
266
|
3. Open the file `main.cpp` (in Sources). Study the `illustration` function and how to call it from the `main` function. Note that the variables `argValue` and `argRef`are initialized to 0 and that the function call for `illustration` makes a pass by value of `argValue` and a pass by reference of `argRef`. Also note that the corresponding parameters in `illustration` are assigned a value of 1.
|
267
|
267
|
|
268
|
|
- void illustration(int paramValue, int ¶mRef) {
|
269
|
|
- paramValue = 1;
|
270
|
|
- paramRef = 1;
|
271
|
|
- cout << endl << "The content of paramValue is: " << paramValue << endl
|
272
|
|
- << "The content of paramRef is: " << paramRef << endl;
|
273
|
|
- }
|
|
268
|
+ void illustration(int paramValue, int ¶mRef) {
|
|
269
|
+ paramValue = 1;
|
|
270
|
+ paramRef = 1;
|
|
271
|
+ cout << endl << "The content of paramValue is: " << paramValue << endl
|
|
272
|
+ << "The content of paramRef is: " << paramRef << endl;
|
|
273
|
+ }
|
274
|
274
|
|
275
|
275
|
4. Execute the program and observe what is displayed in the window `Application Output`. Notice the difference between the content of the variables `argValue` and `argRef` despite the fact that both had the same initial value, and that `paramValue` and `paramRef` were assigned the same value. Explain why the content of `argValor` does not change, while the content of `argRef` changes from 0 to 1.
|
276
|
276
|
|