+ 1

What is function overloading?

10th Dec 2017, 6:19 AM
Vasu Mishra
Vasu Mishra - avatar
2 Answers
+ 11
Function overloading (also method overloading) is a programming concept that allows programmers to define two or more functions with the same name and in the same scope. Each function has a unique signature (or header), which is derived from:function/procedure name. number of arguments. arguments' type. ex:-here sum function is overloaded int sum (int x, int y) { cout << x+y; } int sum(int x, int y, int z) { cout << x+y+z; } Here sum() function is overloaded, to have two and three arguments. Which sum() function will be called, depends on the number of arguments. int main() { sum (10,20); // sum() with 2 parameter will be called sum(10,20,30); //sum() with 3 parameter will be called }
10th Dec 2017, 6:22 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
thanks
10th Dec 2017, 6:24 AM
Vasu Mishra
Vasu Mishra - avatar