Naming convention for params of ctors and setters

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

    I'm going with

    Obj(int foo) : mFoo(foo) { }
    void setFoo(int foo) { mFoo = foo; }
    

    in my programs. For copy constructors and operator=, i tend to call it

    Obj(Obj const& that):mFoo(that.mFoo) { }
    

    For operators, i'm going with

    Obj operator+(Obj const& lhs, Obj const& rhs) { ... }
    

    Because those are the left hand side and the right hand side of it.

提交回复
热议问题