We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 0113f74 + e1b8b4c commit f5c838cCopy full SHA for f5c838c
03-Style.md
@@ -264,6 +264,18 @@ private:
264
// ... //
265
```
266
inside the class body. This makes sure that no constructor ever "forgets" to initialize a member object.
267
+
268
+Use brace initialization, it does not allow narrowing at compile-time:
269
+```cpp
270
+// Best Idea
271
272
+// ... //
273
+private:
274
+ int m_value{ 0 };
275
276
+```
277
+Prefer {} initialization over alternatives unless you have a strong reason not to.
278
279
Forgetting to initialize a member is a source of undefined behavior bugs which are often extremely hard to find.
280
281
0 commit comments