Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In this noncompliant code example, the member initializer list for C::C() attempts to initialize SomeVal first and then to initialize DependsOnSomeVal to a value dependent on SomeVal. Because the declaration order of the member variables does not match the member initializer order, attempting to read the value of SomeVal results in an unspecified value being stored into DependsOnSomeVal.

...

[ISO/IEC 14882-2014]12.6.2, "Initializing Bases and Members"
[Lockheed Martin 05]Rule 75, " Members of the initialization list shall be listed in the order in which they are declared in the class"

 

...