< Previous | Contents | Next >

Overloading Functions

Youve seen how you must specify a parameter list and a single return type for each function you write. But what if you want a function thats more versatileone that can accept different sets of arguments? For example, suppose you want to write a function that performs a 3D transformation on a set of vertices that are represented as floats, but you want the function to work with ints as well. Instead of writing two separate functions with two different names, you could use function overloading so that a single function could handle the different parameter lists. This way, you could call one function and pass vertices as either floats or ints.


 

Introducing the Triple ProgramCreating Overloaded FunctionsCalling Overloaded Functions