|
|
Constructors - initialization versus assignment |
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 |
|
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 |