![]() ![]() ![]() ![]() ![]() ![]() ![]() | Abstraction Mechanisms, Part 1 - slide 8 : 41 |
The main task of a constuctor is to initalize data members
In C++ initialization and assignment must be distinguished
Initialization is controlled by copy constructors, assignment by operator= overloads
![]() | Rectangle constructors - with initialization. |
![]() | Rectangle constructors - with default initialization and subsequent assignments. |
Const data members and references must be initialized - they cannot be assigned in the body of the constructor
Always prefer explicit initialization - the rules for implicit initialization are (too) complicated