Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions 03-Style.md
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,18 @@ private:
// ... //
```
inside the class body. This makes sure that no constructor ever "forgets" to initialize a member object.

Use brace initialization, it does not allow narrowing at compile-time:
```cpp
// Best Idea

// ... //
private:
int m_value{ 0 };
// ... //
```
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.


Expand Down