Why function overloading is required in C++ ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why function overloading is required in C++ ?

i am confused n eager to know why we require function overloading. ??

27th Oct 2018, 2:01 PM
Samarth H Chinivar
Samarth H Chinivar - avatar
3 Answers
+ 1
Function overloading is a very significant feature of c++. As we've learned that C++ is based on OOPS which has polymorphism feature. Function overloading is actually an example of polymorphism in C++. It is necessary where a single function with different passing arguments is written again and again. It makes a program shorter and easy to understand.
27th Oct 2018, 2:26 PM
Kapil Bhatt
Kapil Bhatt - avatar
+ 1
Because in C (-like languages) you have to declare the type of the parameters and their number, and sometimes that becomes an issue. For example you have a function that takes an int for an argument. But now you want the same function for a double or two ints or whatever. To make this possible, you can (have to) define the function again for the different parameter situation.
27th Oct 2018, 2:30 PM
HonFu
HonFu - avatar
+ 1
Probably our two explanations show the standpoint from C ('Look how convenient this is!') and from Python ('Look how combersome it is!') ;)
27th Oct 2018, 2:39 PM
HonFu
HonFu - avatar