next up previous
Up: Return

Notes

Overloading
Overloaded functions do not have to have the same return type. For example, you can overload a square root function to return an int if the argument is int and return a float if the argument is float. See:

References
Ignore most of the lessons ``Changing Parameter Values'' and ``Using C++ References''. The important thing to remember is that if a function is called with some parameter, say par, the function does not usually receive the full information about par. In particular, it only receives the value that is stored in variable par, but no information about where the variable par is actually located in memory. As a result, the function can use, but not modify the value of par.

However, in C++ we can precede the parameter par with an & in the definition of the function, and in its prototypes. In that case, the function will not receive the value of par, but the actual location where par is stored in memory. This gives the function full access to par, and it can now change its value. The parameter is now passed ``by reference'', instead of ``by value''.


next up previous
Up: Return
Author: Leon van Dommelen