Created
December 24, 2018 08:02
-
-
Save Bloofer/4ac045ccd62cdd1dbc8cd2647484490a to your computer and use it in GitHub Desktop.
const example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Bad Idea | |
class MyClass | |
{ | |
public: | |
MyClass(std::string t_value) | |
: m_value(t_value) | |
{ | |
} | |
std::string get_value() | |
{ | |
return m_value; | |
} | |
private: | |
std::string m_value; | |
} | |
// Good Idea | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment