Skip to content

Instantly share code, notes, and snippets.

@alivesay
Last active December 26, 2015 09:08
Show Gist options
  • Select an option

  • Save alivesay/7126836 to your computer and use it in GitHub Desktop.

Select an option

Save alivesay/7126836 to your computer and use it in GitHub Desktop.
C++ initialization list example
class Foo {
public:
void Foo(int p_x);
private:
int _x;
}
void Foo::Foo(int p_x) :
_x(p_x)
{
// do stuff
}
---
// alternative without initialization list
void Foo::Foo(int p_x) {
this->_x = p_x;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment