From 4520dcd62a88638c1f1e155aadbc2781a747a0d5 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Tue, 24 May 2016 22:28:48 -0600 Subject: [PATCH] Update 03-Style.md --- 03-Style.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/03-Style.md b/03-Style.md index 591dadb..9909e69 100644 --- a/03-Style.md +++ b/03-Style.md @@ -274,9 +274,12 @@ Use brace initialization; it does not allow narrowing at compile-time: // ... // 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. Forgetting to initialize a member is a source of undefined behavior bugs which are often extremely hard to find.