it's well knows that compiler implicitly creates an constructor but if we have a code like this:
class A
{
public:
A(int = 0) {}
};
this constructor is default one and conversion operator in same time.
Question:
will compiler generate "empty" default constructor A() {} anyway as well?
No. A default constructor is one that has no arguments or arguments with default values.
So, basically, you already defined the default constructor.
Section 12.1.5 from C++03 states this:
A default constructor for a class X is a constructor of class X that can be called without an argument. [...]
As you can call your constructor without an argument, it is a default one. Ergo, the compiler doesn't need to declare another.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With