0

If I had two function with the same name and the same returned value.. Which one will work .?

3rd Feb 2017, 10:33 PM
ali
ali - avatar
3 ответов
+ 8
You can make multiple functions with the same name, but they must have different arguments (different type(s), different amounts, etc.) to differentiate them. I don't think they can have different return types. This is called function overloading. Depending on what you pass in, it chooses which one to use. Ex: sum(27, 37); //overload for 2 ints sum(18, 75, 5); //overload for 3 ints sum(27.32, 9.99); //overload for 2 doubles
3rd Feb 2017, 11:18 PM
Tamra
Tamra - avatar
+ 1
nope, you can do it but argument list must be different
3rd Feb 2017, 10:49 PM
ihor
0
I Think you Can't Make 2 Functions With The Same Name
3rd Feb 2017, 10:44 PM
Khaled EL-Adawy
Khaled EL-Adawy - avatar