October 2011
Beginner to intermediate
1200 pages
35h 33m
English
There are two main reasons for using reference arguments:
• To allow you to alter a data object in the calling function
• To speed up a program by passing a reference instead of an entire data object
The second reason is most important for larger data objects, such as structures and class objects. These two reasons are the same reasons you might have for using a pointer argument. This makes sense because reference arguments are really just a different interface for pointer-based code. So when should you use a reference? Use a pointer? Pass by value? The following are some guidelines.
A function uses passed data without modifying it:
• If the data object is small, such as a built-in data type or a small structure, ...
Read now
Unlock full access