mem-initializer are performed first in the order they were declared in the class definition and then the body of the constructor is executed.
For reference the draft C++ standard says:
In a non-delegating constructor, initialization proceeds in the following order:
[...]
Then, non-static data members are initialized in the order they were declared in the class definition
(again regardless of the order of the mem-initializers).
Finally, the compound-statement of the constructor body is executed
If you did not assign a value to b
in the body of the constructor it would have an indeterminate value.
To clarify from the answer you mentioned, the part of the answer you seem to be referring to is:
if you use assignment then the fields will be first initialized with
default constructors and then reassigned (via assignment operator)
with actual values.
what they meant to say was that it would be default initialized which in the case for an int means an indeterminate value, from the draft C++ standard:
If no initializer is specified for an object, the object is
default-initialized. When storage for an object with automatic or
dynamic storage duration is obtained, the object has an indeterminate
value, and if no initialization is performed for the object, that
object retains an indeterminate value until that value is replaced
(5.17).
Note that using an indeterminate value is undefined behavior.