Is using underscore suffix for members beneficial?

后端 未结 13 2195
猫巷女王i
猫巷女王i 2020-12-29 03:58
class C {
 private:
  int member_; // here is the underscore I refer to.
}

This underscore is recommended by Google Style Guide and Geosoft\'s C++

13条回答
  •  -上瘾入骨i
    2020-12-29 04:28

    I think it's important to distinguish between class variables and local ones (and global ones if really needed). How you do it, is not important - just be consistent.

    class Foo
    {
      int mMember;
      int member_;
      int _member;
      int m_Member;
    };
    

    All styles give you the information you need. As long as you stay with the same style all of the time, no problem. Sometimes other people need to work with your code (e.g. when you create a library, or you work with a community). Then it might be a good idea to stick with the most used style in the C++ community.

    Sorry - I can't answer what style that is.

提交回复
热议问题