better examples for passing values for safety

Address comments from #37
This commit is contained in:
Jason Turner
2015-08-24 16:15:05 -06:00
parent bf0a81c718
commit d3a6edba2e

View File

@@ -9,18 +9,8 @@
class MyClass class MyClass
{ {
public: public:
MyClass(std::string t_value) void do_something(int i);
: m_value(t_value) void do_something(std::string str);
{
}
std::string get_value()
{
return m_value;
}
private:
std::string m_value;
}; };
@@ -28,19 +18,10 @@ private:
class MyClass class MyClass
{ {
public: public:
MyClass(const std::string &t_value) void do_something(const int i);
: m_value(t_value) void do_something(const std::string &str);
{
}
std::string get_value() const
{
return m_value;
}
private:
std::string m_value;
}; };
``` ```
### Consider Return By Value for Mutable Data, `const &` for Immutable ### Consider Return By Value for Mutable Data, `const &` for Immutable