+ 1

Is overloading compatible with default values in C++ or Java?

I guess no (causing ambiguity) and test it with some codes but still not sure.

20th Dec 2017, 6:06 AM
Bo Yang
Bo Yang - avatar
1 Odpowiedź
+ 1
It is allowed in general, but just like constructors, ambiguity knocks out the rare cases. But cases like these are allowed: void print() { cout<<2<<endl; } void print(int k, char c = 'a') { cout<<k<<" "<<c<<endl; }
20th Dec 2017, 9:53 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar