Lesson 05: Function Overloading and Default Arguments
5.1 Function Overloading
Function overloading is a feature in C++ that you can use the same name for different functions. Function overloading can be considered as an example of a polymorphism feature in C++.
Functions in C
Suppose there is a function that calculates the average of an array of numbers of type int. The function might look like this:
float iAverage(int array[], int length) { int sum = 0; int j; for (j = 0; j < length; j++) sum += array[j]; return (float) sum / length ; }
2
3
5.2 Default Arguments