What does `m_` variable prefix mean?

前端 未结 9 755
太阳男子
太阳男子 2020-12-22 18:47

I often see m_ prefix used for variables (m_World,m_Sprites,...) in tutorials, examples and other code mainly related

9条回答
  •  太阳男子
    2020-12-22 19:01

    As stated in the other answers, m_ prefix is used to indicate that a variable is a class member. This is different from Hungarian notation because it doesn't indicate the type of the variable but its context.

    I use m_ in C++ but not in some other languages where 'this' or 'self' is compulsory. I don't like to see 'this->' used with C++ because it clutters the code.

    Another answer says m_dsc is "bad practice" and 'description;' is "good practice" but this is a red herring because the problem there is the abbreviation.

    Another answer says typing this pops up IntelliSense but any good IDE will have a hotkey to pop up IntelliSense for the current class members.

提交回复
热议问题