Chapter 4, Indirect Addressing: References
- a – c. Please see
Assessments/Chapter04/Chp4-Q1.cpp
in the GitHub repository.
c. (follow-up question) Pointer variables need not only call the version of ReadData(Student *)
that accepts a pointer to a Student
and reference variables need not only call the version of ReadData(Student &)
that accepts a reference to a Student
. For example, a pointer variable may be dereferenced with *
and then call the version that accepts a reference. Likewise, a reference variable may have its address taken using &
and then call the version that accepts a pointer (though this is less commonly done). You simply need to make the data types match with respect to what you are passing and what the function expects.