I have been playing around with default constructors and noticed a weird behavior (from my point of view).
When I declare A() = default
, I get no linker error.
struct A
{
int a;
A() = default;
};
A a; // no linker error
However, when I declare A();
I get it.
struct A
{
int a;
A();
};
A a; // linker error - undefined reference to `A::A()`
Questions:
-
What's the difference between the two?
-
And if
A();
produces a linker error, why is it supported in the first place? Any practical applications?
Aucun commentaire:
Enregistrer un commentaire