Skip to content

Instantly share code, notes, and snippets.

@ElFeesho
Created November 29, 2015 21:10
Show Gist options
  • Save ElFeesho/d897f38af7498b624ffe to your computer and use it in GitHub Desktop.
Save ElFeesho/d897f38af7498b624ffe to your computer and use it in GitHub Desktop.
class MyObject
{
public:
MyObject(int someInt)
{
this->someInt = someInt; // someInt will be allocated and then set to a value separately (inefficient)
}
private:
int someInt;
};
ALTERNATIVE
class MyObject
{
public:
MyObject(int anInt) : someInt(anInt) {} // Some int initialised and allocated at the same time
private:
int someInt;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment