Computer Science, asked by vidushiprakashagniho, 7 months ago

illustrate the concept of function overloading with the help of an example.​

Answers

Answered by mahenpatel
1

Answer:

Function overloading is a C++ programming feature that allows us to have more than one function having same name but different parameter list, when I say parameter list, it means the data type and sequence of the parameters,

Answered by lalitnit
3

Answer:

Function overloading

Function overloading is a C++ programming feature that allows us to have more than one function having same name but different parameter list, when I say parameter list, it means the data type and sequence of the parameters, for example the parameters list of a function myfuncn(int a, float b) is (int, float) which is different from the function myfuncn(float a, int b) parameter list (float, int). Function overloading is a compile-time polymorphism.

Function overloading Example

Lets take an example to understand function overloading in C++.

#include <iostream>

using namespace std;

class Addition {

public:

int sum(int num1,int num2) {

return num1+num2;

}

int sum(int num1,int num2, int num3) {

return num1+num2+num3;

}

};

int main(void) {

Addition obj;

cout<<obj.sum(20, 15)<<endl;

cout<<obj.sum(81, 100, 10);

return 0;

}

Output:

35

191

Similar questions