mirror of
https://github.com/cpp-best-practices/cppbestpractices.git
synced 2025-12-17 11:14:35 +03:00
Update 03-Style.md
This commit is contained in:
@@ -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.
|
||||||
|
|||||||
Reference in New Issue
Block a user