In what order are non-static data members initialized?

The order is the order they appear in the class definition – this is from section 12.6.2 of the C++ Standard: 5 Initialization shall proceed in the following order: — First, and only for the constructor of the most derived class as described below, virtual base classes shall be initialized in the order they appear … Read more

Is it idiomatic to store references members in a class, and are there pitfalls?

Is there a name to describe this idiom? In UML it is called aggregation. It differs from composition in that the member object is not owned by the referring class. In C++ you can implement aggregation in two different ways, through references or pointers. I am assuming it is to prevent the possibly large overhead … Read more

GCC issue: using a member of a base class that depends on a template argument

David Joyner had the history, here is the reason. The problem when compiling B<T> is that its base class A<T> is unknown from the compiler, being a template class, so no way for the compiler to know any members from the base class. Earlier versions did some inference by actually parsing the base template class, … Read more

C++11 allows in-class initialization of non-static and non-const members. What changed?

The short answer is that they kept the linker about the same, at the expense of making the compiler still more complicated than previously. I.e., instead of this resulting in multiple definitions for the linker to sort out, it still only results in one definition, and the compiler has to sort it out. It also … Read more