Naming convention - underscore in C++ and C# variables

前端 未结 19 2325
春和景丽
春和景丽 2020-11-28 01:11

It\'s common to see a _var variable name in a class field. What does the underscore mean? Is there a reference for all these special naming conventions?

19条回答
  •  孤独总比滥情好
    2020-11-28 01:50

    _var has no meaning and only serves the purpose of making it easier to distinguish that the variable is a private member variable.

    In C++, using the _var convention is bad form, because there are rules governing the use of the underscore in front of an identifier. _var is reserved as a global identifier, while _Var (underscore + capital letter) is reserved anytime. This is why in C++, you'll see people using the var_ convention instead.

提交回复
热议问题