Skip to content

Commit 4520dcd

Browse files
committed
Update 03-Style.md
1 parent 01ab3b9 commit 4520dcd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

03-Style.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,9 +274,12 @@ Use brace initialization; it does not allow narrowing at compile-time:
274274

275275
// ... //
276276
private:
277-
int m_value{ 0 };
277+
int m_value{ 0 }; // allowed
278+
unsigned m_value_2 { -1 }; // compile-time error, narrowing from signed to unsigned.
278279
// ... //
279280
```
281+
282+
280283
Prefer {} initialization over alternatives unless you have a strong reason not to.
281284
282285
Forgetting to initialize a member is a source of undefined behavior bugs which are often extremely hard to find.

0 commit comments

Comments
 (0)