Which class members MUST be initialised in a constructor’s member initialiser list (or with a default member initialiser) rather than assigned in the constructor body?
Correct answer A. const data members and reference members
By the time the constructor body runs, every member has already been initialised. A const member cannot be assigned afterwards and a reference cannot be reseated, so both must be given their values in the initialiser list or by a default member initialiser. Members of class types without a default constructor have the same requirement. Static members are defined outside the constructor altogether.
Answer checked How we write and check questions
Discussion