From d3a6edba2e0fe66b08ab7b7c81e4c172c0618ec3 Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Mon, 24 Aug 2015 16:15:05 -0600 Subject: [PATCH] better examples for passing values for safety Address comments from #37 --- 04-Considering_Safety.md | 29 +++++------------------------ 1 file changed, 5 insertions(+), 24 deletions(-) diff --git a/04-Considering_Safety.md b/04-Considering_Safety.md index 06a8db8..e802458 100644 --- a/04-Considering_Safety.md +++ b/04-Considering_Safety.md @@ -9,18 +9,8 @@ class MyClass { public: - MyClass(std::string t_value) - : m_value(t_value) - { - } - - std::string get_value() - { - return m_value; - } - -private: - std::string m_value; + void do_something(int i); + void do_something(std::string str); }; @@ -28,19 +18,10 @@ private: class MyClass { public: - MyClass(const std::string &t_value) - : m_value(t_value) - { - } - - std::string get_value() const - { - return m_value; - } - -private: - std::string m_value; + void do_something(const int i); + void do_something(const std::string &str); }; + ``` ### Consider Return By Value for Mutable Data, `const &` for Immutable