Here is the definition of function overloading:
Function overloading or meth overloading is the ability to create multiple methods of same name with different implementations:
Here is an example, (in C++)
#include <iostream>
// volume of a cube
int volume(int s)
{
return s*s*s;
}
// volume of a cylinder
double volume(double r, int h)
{
return 3.14*r*r*static_cast<double>(h);
}
// volume of a cuboid
long volume(long l, int b, int h)
{
return l*b*h;
}
int main()
{
std::cout << volume(10);
std::cout << volume(2.5, 8);
std::cout << volume(100, 75, 15);
}
then it will shows that the "function overloading";