Current location - Quotes Website - Signature design - In C++, there will be an error when calling the class method after creating an instance of the default constructor.
In C++, there will be an error when calling the class method after creating an instance of the default constructor.
This problem is caused by the default value of the function.

a(int w = 15){ weight = w+5; } is actually equivalent to two declarations, namely a () with default value and A(int) without default value.

The compiler version you are using is relatively old. The first one will directly prompt an error instead of a warning. Obviously, this is also one of the common mistakes when overloading functions. Remember that the function signature with default value includes several (default value+1) different call signatures. If there is a conflict, it will lead to a compile-time error: the compiler cannot determine which one to call.

The second error is a subsequent error, because the first error cannot determine which to call.

The other anonymous ... I'm a farmer.