Trailing underscores for member variables in C++

前端 未结 7 409
后悔当初
后悔当初 2020-12-13 03:46

I\'ve seen people use a trailing underscore for member variables in classes, for instance in the renowned C++ FAQ Lite.

I think that it\'s purpose is not to mark var

7条回答
  •  有刺的猬
    2020-12-13 04:26

    As a maintenance developer that likes searchability I'm leaning towards m_ as its more searchable. When you, as me, are maintaining big projects with large classes (don't ask) you sometimes wonder: "Hmmm, who mutates state?". A quick search for m_ can give a hint.

    I've also been known to use l_ to indicate local variables but the current project doesn't use that so I'm "clean" these days.

    I'm no fan of hungarian notation. C++ has a strong type system, I use that instead.

提交回复
热议问题