Benifits of function overloading in c++ program? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Benifits of function overloading in c++ program?

why we need function overloading in c++ ? or what are the benifits of function overloading in c++ program?

18th Oct 2017, 1:47 AM
Waqas Ahmed
Waqas Ahmed - avatar
2 Answers
+ 3
@Jonathan _ answer is sound and clear, you should keep what he said in mind A little more technical but you ABSOLUTELY NEED function overloading with variadic templates. I will not explain them here because they are quite complex. If you want an explanation about them,ask and I'll tell you but just know that you need a good understanding of classical templates to start learning variadic ones
18th Oct 2017, 10:58 PM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
If you want to create a function to add a e.g. Date, you can overload a function addDate(Date date), and another one addDate(int day, int month, in year) This way you can either add a date-struct or the date by single values.
18th Oct 2017, 5:46 PM
Jonathan _
Jonathan _ - avatar