Skip to content
Open
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
20 changes: 11 additions & 9 deletions 03-Style.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,23 @@ struct Size
int width;
int height;

Size(int t_width, int t_height) : width(t_width), height(t_height) {}
constexpr explicit Size(int t_width, int t_height) : width(t_width), height(t_height) {}
};

// This version might make sense for thread safety or something,
// but more to the point, sometimes we need to hide data, sometimes we don't.
class PrivateSize
{
public:
int width() const { return m_width; }
int height() const { return m_height; }
PrivateSize(int t_width, int t_height) : m_width(t_width), m_height(t_height) {}

private:
int m_width;
int m_height;
public:
constexpr int width() const noexcept { return m_width; }
constexpr int height() const noexcept { return m_height; }

constexpr explicit PrivateSize(int t_width, int t_height)
: m_width(t_width), m_height(t_height) {}

private:
int m_width;
int m_height;
};
```

Expand Down