Why should I initialize member variables in the order they're declared in?

The reason is because they're initialized in the order they're declared in your class, not the order you initialize them in the constructor and it's warning you that your constructor's order won't be used.

This is to help prevent errors where the initialization of b depends on a or vice-versa.

The reason for this ordering is because there is only one destructor, and it has to pick a "reverse order" to destroy the class member. In this case, the simplest solution was to use the order of declaration within the class to make sure that attributes were always destroyed in the correct reverse order.


Why should I initialize member variables in the order they're declared in?

The members will be initialized in the same order they are declared, whether you want it or not. The warning is telling you that the order you are asking for differs from the actual order of execution of initialization.


You shouldn't because it decreases readability and is potentially misleading.

If you did:

Test() : b(1), a(b) {}

it would appear that b then a were both set to 1, whereas actually the uninitialized value of b is used to initialize a before b is initialized to 1.