October 2004
Intermediate to advanced
240 pages
6h 22m
English
Agree with your compiler: Member variables are always initialized in the order they are declared in the class definition; the order in which you write them in the constructor initialization list is ignored. Make sure the constructor code doesn’t confusingly specify a different order.
Consider the code below:

This code harbors a bug that’s as pernicious as it is hard to spot. Because email_ is declared before first_ and last_ in the class definition, it will be initialized first and will attempt to use the other not-yet-initialized fields. Worse, if the constructor’s ...