You are given a C++ class type T.
-
When will the compiler
implicitly declare
a default constructor for
T
?
-
When will the implicitly-declared default constructor be
defined as deleted
(i.e.,
T t;
is ill-formed)?
-
How do user-declared special member functions (copy/move ctor, copy/move assignment, destructor) affect whether a default constructor is generated?
-
What changes if members/base classes have no default constructors, are references, or are
const
?
Answer in terms of the C++ “special member functions” model (rule of 0/3/5) and include a few small examples of classes that:
-
get an implicit default constructor,
-
do not get one,
-
get one but it is deleted.