Computer Science, asked by tamilinba1103, 1 year ago

explain function overloading, need of function overloading with example

Answers

Answered by StaceeLichtenstein
2

Following are the explanation of function overloading that is given below

Explanation:

  • Function having same name with the different parameter then this type of phenomena is known as function overloading .
  • Need of Function overloading:To achieve the compile time binding we have used the concept function overloading .
  • For example .In c++ program

#include <iostream>  // header file

using namespace std;  // namespace

class test // class test

{

public:  // access modifier

   void fun2() // function

{

cout<<" hello brainly ";        

  }

   int fun2(int a1,int a2) // function

{

      return a1+a2;

   }

};

int main()

{

test ob3;  // create the object

   cout<<ob3.fun2()<<endl;  // calling function

   cout<<ob3.fun2(81, 19);  // calling function

   return 0;

}

Output:

hello brainly

100

  • In this program the function name is same i.e fun2() but the argument are different .The compiler call the function with detecting the argument in the function.

Learn More:

  • https://brainly.in/question/6360490
Answered by 0xXIshuRajputXx0
1

Answer:

It will be the sum of the currents drawn by the devices and can be greater than what is safe , This condition is called an overload .

Explanation:

Similar questions