Next: Call-by-reference parameters Up: Introduction to C++ Programming Previous: Exercises


Further User-defined functions in C++

In Lesson 21 all function parameters were input-only parameters and thus were implemented as call-by value parameters. The only method used to return information to the calling program was by the function returning a single value. Frequently it is necessary to write functions that return more than one value. For example a function that took a sum of money in pence might have to return the equivalent sum in pounds and pence.

To allow information to be returned to the calling program C++ allows information to be returned by parameters. As explained in Lesson 21 this cannot be done by the use of call-by-value parameters. To allow a parameter to return a value it must be declared to be a call-by-reference parameter.



Subsections

Next: Call-by-reference parameters Up: Introduction to C++ Programming Previous: Exercises