...
Non-Compliant Code Example
Code Block | ||||
---|---|---|---|---|
| ||||
class C { int a; int b; public: C() : b(3), a(b+1) {} }; |
...
This code reorders the initializers correctly:
Code Block | ||||
---|---|---|---|---|
| ||||
class C { int a; int b; public: C() : a(b+1), b(3) {} }; |
...
This code resolves the dependency.
Code Block | ||||
---|---|---|---|---|
| ||||
class C { int a; int b; public: C() : a(4), b(a-1) {} }; |
...