+ 1
Default constructor vs default argument
Can someone explain why this code produces no output? And also, why is it when I create an object with parentheses instead it gives an error instead? https://code.sololearn.com/cfPBOo2J4B0Q/?ref=app
3 Respuestas
+ 2
About creating the object using empty parenthesis, I found this:
https://stackoverflow.com/a/181463
+ 3
The overloaded constructor has a parameter, but it has a default value, so it's optional. Being optional, it means the second constructor accepts being called with no arguments - which the first one accepts too, so the redundance error.
0
Emerson Prado huh that is interesting, I wouldn’t have guessed that, thanks for the link!