getters and setters style

前端 未结 13 2353
猫巷女王i
猫巷女王i 2021-01-01 12:05

(Leaving aside the question of should you have them at all.)

I have always preferred to just use function overloading to give you the same name for both getter and s

13条回答
  •  离开以前
    2021-01-01 12:12

    I'll go ahead and mention this should be a community wiki question.

    When I started learning C++ I looked for style guides, and Google's was good for some points:

    • Methods in uppercase (it's just prettier).
    • getters plainly and lowecase (rate).
    • setters explicitly and lowercase (setRate).

提交回复
热议问题