next up previous
Next: Pointers Up: function Previous: function

Getting More Out of Subprograms

In the previous Newton-Raphson example we got the value of the function and its derivative through separate subprogram calls. Each function subprogram had a single input argument, namely x and a single output value, which was passed back to the calling program as the function return value. It is frequently convenient to have several input and output values. To illustrate let's see how to rewrite the Newton-Raphson subprograms so a single call does double duty by returning the value of the function and its derivative. This objective takes us into the realm of pointers and references, which we discuss in more detail in the next lesson. Here we introduce the terminology and the pattern, first, using pointers and second, using references.


Carleton DeTar 2009-09-23