As discussed, functions can only return one value. What if you need to get two values back from a function? One way to solve this problem is to pass two objects into the function, by reference. The function can then fill the objects with the correct values. Because passing by reference enables a function to change the original objects, this effectively lets the function return two pieces of information. This approach bypasses the return value of the function, which can then be reserved for reporting errors.
Once again, this can be done with references or pointers. Listing 11.7 demonstrates a function that returns three values, two as pointer parameters and one as the return value of the function.