Versions Compared

Key

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

...

Non-Compliant Code Example

Code Block
bgColor#FFcccc
langcpp
class C {
  int a;
  int b;
public:
  C() : b(3), a(b+1) {}
};

...

This code reorders the initializers correctly:

Code Block
bgColor#FFcccc
langcpp
class C {
  int a;
  int b;
public:
  C() : a(b+1), b(3) {}
};

...

This code resolves the dependency.

Code Block
bgColor#ccccff
langcpp
class C {
  int a;
  int b;
public:
  C() : a(4), b(a-1) {}
};

...