Naming convention for params of ctors and setters

前端 未结 12 1819
轻奢々
轻奢々 2021-01-05 00:42

For those of you who name you member variables with no special notation like m_foo or foo_, how do you name parameters to your ctors and setters?

12条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-05 01:36

    I do it like this:

    obj(int foo) : _foo(foo) { }
    int foo() const { return _foo; }
    void foo(int value) { _foo = value; }
    

    The only trick here is to make sure that the letter following the underscore is lowercase. However, I avoid uppercase in identifier names everywhere, as it is inconsistent with conventions used by the standard library (which uses foo_bar_baz for all identifiers).

提交回复
热议问题