-
Notifications
You must be signed in to change notification settings - Fork 822
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Normalize constructor parameter names (#1427)
* Normalize constructor parameter names In order to avoid confusion between constructor parameter names and member variables, we either used alternate names for the parameters or prefixed the parameter names with an underscore. For example: class foo { public: foo(int _i, bool semaphore, short bar) : i(_i), flag(semaphore) { baz = bar; } private: int i; bool flag; short baz; }; However, this is unnecessary. Constructor initializer lists are unambiguous, as the assigned item always refers to the class member, and the assigned value is always from the parameter (unless prefixed with "this->"). Inside the constructor body, parameter names override member variables, and "this->" can be used to indicate the class member in the case of name collision. Thus, the above code can be rewritten as this: class foo { public: foo(int i, bool flag, short baz) : i(i), flag(flag) { this->baz = baz; } private: int i; bool flag; short baz; }; I've taken advantage of this to clarify names used in constructors throughout the codebase. Mostly for constructor parameter names, sometimes for member variable names. * Refine names from review feedback
- Loading branch information
Showing
24 changed files
with
201 additions
and
189 deletions.
There are no files selected for viewing
This file contains 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
Oops, something went wrong.