Overloading with default parameters | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Overloading with default parameters

if 2 methods of the same name have parameters with default values defined, how is overloading resolved?

22nd Dec 2016, 11:38 AM
ifl
ifl - avatar
1 Answer
+ 1
parameters type must be difference. Example: You have 2 methods 1-A(int a) and 2-A(float A). If you call A(1), the first method was called, otherwise A(1.0), second method fire. If you call function with no parameters, exception raise ...
22nd Dec 2016, 4:42 PM
Quốc Hùng