Skip to content

Instantly share code, notes, and snippets.

@Bloofer
Created December 24, 2018 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bloofer/4ac045ccd62cdd1dbc8cd2647484490a to your computer and use it in GitHub Desktop.
Save Bloofer/4ac045ccd62cdd1dbc8cd2647484490a to your computer and use it in GitHub Desktop.
const example
// 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