0
If I had two function with the same name and the same returned value.. Which one will work .?
3 Réponses
+ 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
+ 1
nope, you can do it but argument list must be different
0
I Think you Can't Make 2 Functions With The Same Name