Last active
December 26, 2015 09:08
-
-
Save alivesay/7126836 to your computer and use it in GitHub Desktop.
C++ initialization list example
This file contains hidden or 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
| 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