Function Overloading

What is Overloading?

Overloading is essentially using the same name for
multiple functions or methods. How does the compiler know how to differentiate between them?
Each overloaded function must have a different signature.
The signature consists of the return value, function name and the parameters.
If we change the types or number of paramters of a function but keep the name the same,
we create an overloaded function.

Contents of main.cpp :

#include <iostream>
#include <stdlib.h>
using namespacestd;

First we create a function called decreasingNumbers that
takes 2 parameters. The first parameter is the number to start from. The function will print
out all values from this start value down to the value given by the second parameter.

We create another function called decreasingNumbers but this
time we only have one parameter indicating what value to count from. This function counts
all the way down to 0. Instead of using similar code to
the code above, we just call the function above and pass 0
as the second parameter.

void decreasingNumbers(int from)
{
decreasingNumbers(from, 0);
}

Below we use both functions. The first prints all values from 10 to 5
and the other prints all values from 7 to 0.

You should now have an understanding of what function overloading
is. This is very useful in certain situations where you want to create a function that has
the same purpose but requires different inputs.