Chapter 2.4

C.47: Define and initialize member variables in the order of member declaration

There is only one order of initialization of member data, which is the order of decla-ration. You cannot change this. There are very good reasons for this being an immu-table rule, which we will describe in this chapter.

But first, an example. Bryn, a new engineer at a large firm, is asked to write a pop-ulation service for finding out how many people are in the building. A server locked away in the bowels of the building handles admissions and exits. It is old and slow. Etched on the front in red lettering is the name of a forgotten hardware company long ago sold to a rapacious and overfunded startup. Queries are rather cumber-some and time consuming. ...

Get Beautiful C++: 30 Core Guidelines for Writing Clean, Safe, and Fast Code now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.