Explain function overloading with example

Function overloading means, two or more functions have the same names but different argument lists
The arguments may differ in the type of arguments or number of arguments, or both. However, the return types of overloaded methods can be the same or different is called function overloading.
Function overloading concepts helps us to use the same function names multiple time in the same program
Example:
Following program demonstrates the overloaded function to find the sum of two integers, sum of two floating-point numbers, and the sum of three integers
#include<iostream> using namespace std; int sum(int x, int y) { return x+y; } double sum(double x, double y) { return x+y; } int sum (int x, int y, int z) { return x+y+z; } int main() { cout <<"The Sum of two integers: "<<sum(10, 20)<<endl; cout <<"The Sum of two floats: "<<sum(10.5, 20.7)<<endl; cout <<"The Sum of three integers: "<<sum(10, 20, 30)<<endl; }
OUTPUT: The Sum of two integers: 30 The Sum of two floats: 31.2 The Sum of three integers: 60