Step 4: Passing Arguments "By-Reference"

Now, we will practice "pass-by-reference" parameter-passing. Recall from lecture that when we use "call-by-reference", we are no longer working with a copy of the caller's arguments, but with the actual original. Therefore, modifying these parameter variables will affect the values of variables in the caller's context.

This step is quite easy. Just cut-and-paste the entire definition of MungeRecord() from Step 3 and rename the new copy of the function as tMungeRecordForReal(). Then, modify the function's parameter specification to indicate that the parameter is "pass-by-reference"--try to recall how to do this from lecture. If you can't remember, the TA will tell you what to do... but you'll learn more if you try to do it yourself. It's just one special character before the parameter name!

Because the body of this function is the same as MungeRecord(), it will behave much the same.

After writing this function, you should add the necessary function declaration for MungeRecordForReal() at the top of your file, above main().

For the second part of this step, add a call in main() to MungeRecordForReal(), right after the code you added in the previous step. You should be able to cut-and-paste to duplicate the code you added into main() for Step 3, simply modifying the name of the function called. Don't forget to also duplicate the part that outputs the values of the members of myRec, just as for Step 3.

What do you observe for this step?