From what cppref says about value initialization
if T is a class type with no default constructor or with a user-provided or deleted default constructor, the object is default-initialized;
But since that class type has deleted default constructor, how could the object be default-initialized?
As far as I know, default initialization of class type needs the access of default constructor. If class A
has deleted default ctor, then A *a=new A;
will cause error, so does A* a=new A();
.
By the way, A a{}
is OK,but also according to cppref
Otherwise, If the braced-init-list is empty and T is a class type with a default constructor, value-initialization is performed.
Aucun commentaire:
Enregistrer un commentaire