Exercises in this lecture  previous -- Keyboard shortcut: 'p'        Go to the slide, where this exercise belongs -- Keyboard shortcut: 'u'  

Exercise 5.3
Passing references as ref parameters


In the Date and Person classes of the corresponding slide we pass a reference as a value parameter to method DayDifference in class Date. Be sure to understand this. Read about ref parameters later in this lecture.

Assume in this exercise that the formal parameter other in Date.DayDifference is passed by reference (as a C# ref parameter). Similarly, the actual parameter dateOfBirth to DayDifference should (of course) be passed by reference (using the keyword ref in front of the actual parameter).

What will be the difference caused by this program modification.

Test-drive the program with a suitable client to verify your answer.


Solution