+ 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.
1 Réponse
+ 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;
}