Skip to content

Commit d3a6edb

Browse files
committed
better examples for passing values for safety
Address comments from #37
1 parent bf0a81c commit d3a6edb

File tree

1 file changed

+5
-24
lines changed

1 file changed

+5
-24
lines changed

04-Considering_Safety.md

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,38 +9,19 @@
99
class MyClass
1010
{
1111
public:
12-
MyClass(std::string t_value)
13-
: m_value(t_value)
14-
{
15-
}
16-
17-
std::string get_value()
18-
{
19-
return m_value;
20-
}
21-
22-
private:
23-
std::string m_value;
12+
void do_something(int i);
13+
void do_something(std::string str);
2414
};
2515

2616

2717
// Good Idea
2818
class MyClass
2919
{
3020
public:
31-
MyClass(const std::string &t_value)
32-
: m_value(t_value)
33-
{
34-
}
35-
36-
std::string get_value() const
37-
{
38-
return m_value;
39-
}
40-
41-
private:
42-
std::string m_value;
21+
void do_something(const int i);
22+
void do_something(const std::string &str);
4323
};
24+
4425
```
4526

4627
### Consider Return By Value for Mutable Data, `const &` for Immutable

0 commit comments

Comments
 (0)