"m_"变量前缀是什么意思? [英] What does `m_` variable prefix mean?
问题描述
在教程,示例和其他主要与游戏开发相关的代码中,我经常看到 m_
用作变量的前缀(m_World
,m_Sprites
,...).
I often see m_
prefix used for variables (m_World
,m_Sprites
,...) in tutorials, examples and other code mainly related to game development.
人们为什么要在变量前添加前缀m_
?
Why do people add prefix m_
to variables?
推荐答案
这是用于定义作为成员变量的变量的典型编程实践.因此,以后使用它们时,无需查看定义它们的位置即可知道它们的范围.如果您已经知道范围并且使用的是类似 intelliSense 的东西,那么这也很棒,您可以从m_
开始,并显示所有成员变量的列表.匈牙利符号的一部分,请参见此处的示例中的有关范围的部分.
This is typical programming practice for defining variables that are member variables. So when you're using them later, you don't need to see where they're defined to know their scope. This is also great if you already know the scope and you're using something like intelliSense, you can start with m_
and a list of all your member variables are shown. Part of Hungarian notation, see the part about scope in the examples here.
这篇关于"m_"变量前缀是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!