+ 2

Function overloading with same parameters?

how to use funtion overloading when two functions require exactly same parameters? https://code.sololearn.com/cJ31O3suzyxE/?ref=app Please help me! Checkout code for more information!

10th Mar 2019, 5:00 AM
Nitin Madas
Nitin Madas - avatar
7 Réponses
+ 2
Well you can't over load funtions with the same parameters​. How is the compiler supposed to know which one you are using? A more usual case would be to have an​ area function and parimiter function and over load for different shapes. If you really must solve this using overloading​, then you could have 1 use float types. Or you could have an extra unused parameter in one function.
10th Mar 2019, 7:07 AM
Jared Bird
Jared Bird - avatar
+ 2
Well I have no idea how your teacher would react to being told their wrong. If the question is worded how it's in the comment, you might be better to use one of the hacky solutions I suggested. I is important to be semantically​ correct or just technically correct?
10th Mar 2019, 8:29 AM
Jared Bird
Jared Bird - avatar
+ 2
Hi... Overloaded functions may or may not have different return type but it should have different argument(s). Refer - https://www.programiz.com/cpp-programming/function-overloading Hope this is helpful...!
10th Mar 2019, 8:57 AM
Kuri
Kuri - avatar
+ 2
Serena Yvonne thank you so much!
10th Mar 2019, 9:20 AM
Nitin Madas
Nitin Madas - avatar
+ 1
Jared Bird According to your answer it seems that the question doesn't makes any sense! What should I do now should? what should I tell my teacher?
10th Mar 2019, 7:51 AM
Nitin Madas
Nitin Madas - avatar