Naming convention for params of ctors and setters

前端 未结 12 1916
轻奢々
轻奢々 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:34

    For classes:

    Obj(int foo) : _foo(foo) {};
    

    For structs:

    obj_t(int foo_) : foo(foo_) {};
    

    Setter:

    Obj.setFoo(int foo) { _foo = foo; }
    

    I'm with litb on the use of lhs and rhs for operator calls.

    I use camelCase for class member functions, and names_with_underscores for struct fields and methods.

提交回复
热议问题