Lecture 4 - Slide 6 : 40
More about constructors
Additional properties of constructors in C++
The C++ Prog. Lang. (3. edition)
:
Page 226, 247, 270
The C++ Prog. Lang. (4. edition)
: Page 455
Explicit constructors
By means of an
explicit
specifier before the constructor
Cannot be used in implicite type conversion
Deleting with
= delete
in C++11
It is possible to delete a constructor (or any other function) that has been generated automatically
For instance deleting a copy constructor, such that an object cannot be copied
Defaulting with
= default
in C++11
It is possible to emphasize that we actually want to have an automatically generated function
For instance to document that the automatically generated copy constructor exists
The C++ Prog. Lang. (4. edition)
: explicit, default, delete. Page 457, 519, 524
Examples on the next slide