Function Overloading C++
05:20 26 Dec 2025

Function overloading by difficult number argument and float value assign 10.10 output 10 <

Really Function overloading allows us to define multiple functions with the same name but different parameters. It is a form of compile time polymorphic in which different functions with same name can perform different jobs based on the different parameters passed.

  • Avoids name conflicts and unnecessary function names (explained in the below example)

  • Makes the code easy to understand and making user friendly as the same meaningful function name is used for different types of inputs.

  • Makes the code easy to understand and making user friendly as the same meaningful function name is used for different types of inputs.

#include  //import libary c++
using namespace std; //fiest using std::cout << only using cout fast leaning
int add(int,int); //first call 
int add(int, int, int); //second call
int a;
int main()
{
    cout << "You Have Call First Argument :" << add(10,10) << "\n";
    cout << "enter value P:";
    cin >> a; //enter your number 10.10
    cout << a <<"\n"; //new line a print Only outputs  10
    cout << "You Have Call Secound Argument :" << add(a, 90, 2) << "\n"; 
    return 0 ;
}

int add(int a , int b){
    return a + b; //first run function
}

int add(int p,int r,int n){
    return (p + r) / n; //second run function
}
// output
// float value not  floating only 10 showing 
// c++ rules 
c++11 visual-c++