Created
October 18, 2015 08:02
-
-
Save joyhuang9473/256d5d2018babb1c1491 to your computer and use it in GitHub Desktop.
Constructor initializer lists can be all on one line or with subsequent lines indented four spaces.
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
// When it all fits on one line: | |
MyClass::MyClass(int var) : some_var_(var), some_other_var_(var + 1) {} | |
// When it requires multiple lines, indent 4 spaces, putting the colon on | |
// the first initializer line: | |
MyClass::MyClass(int var) | |
: some_var_(var), // 4 space indent | |
some_other_var_(var + 1) { // lined up | |
... | |
DoSomething(); | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment