Update 03-Style.md

This commit is contained in:
Jason Turner
2016-05-24 22:28:48 -06:00
parent 01ab3b9fa5
commit 4520dcd62a

View File

@@ -274,9 +274,12 @@ Use brace initialization; it does not allow narrowing at compile-time:
// ... // // ... //
private: private:
int m_value{ 0 }; int m_value{ 0 }; // allowed
unsigned m_value_2 { -1 }; // compile-time error, narrowing from signed to unsigned.
// ... // // ... //
``` ```
Prefer {} initialization over alternatives unless you have a strong reason not to. Prefer {} initialization over alternatives unless you have a strong reason not to.
Forgetting to initialize a member is a source of undefined behavior bugs which are often extremely hard to find. Forgetting to initialize a member is a source of undefined behavior bugs which are often extremely hard to find.