Naming convention for params of ctors and setters

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

    I tend to follow the first letter of the parameter that is being set, and disambiguate with this...

    void setFoo(int f) { foo = f; }
    

    For a simple setter, for one variable, it is pretty well clear.

    Also, I often do this

    int setFoo(const int f) { foo = f; }
    

    so I can string things together.

提交回复
热议问题