+ 1

does optional arguments considered as overloading the method ?

1st Mar 2017, 10:38 AM
Qusai
1 Réponse
0
No. Function overloading two or more methods with same name and different number of parameters, data types.We are look at the method signature. int sum(int a, int b) int sum(int a, int b, int c) Optional parameter int add(int a, int b=1) but if u try below with the above 'add' function. int add(int a, int b) compiler gives some error: "already defines a member called 'sum' with the same parameter types"
2nd Mar 2017, 2:46 PM
Eranga
Eranga - avatar