Function-Overloading in c++ .

In this session i have discussed function overloading in C++ .

The function overloading is the new feature in C++ . In function overloading there are many method with same name but their parameters (arguments) are different .

Example : Write a program that demonstrate the function overloading .

  using namespace std; 
  int sum(int x,int y)
  int sum(int x,int y , int z)
  int main()
       int x,y,z;
       cout<<"\nSum function with two arguments  ";
       cout<<"\nSum :  "<<sum(x,y);
       cout<<"\nSum function with three arguments  ";
       cout<<"\nSum :  "<<sum(x,y,z);
       return 0;
  OUTPUT : Sum function with two arguments
           Sum : 30
           Sum function with three arguments
           Sum : 60

Welcome to AndroidATPoint.

back image                     next image