普遍接受的变量名称格式 - C / C ++ [英] Commonly Accepted Variable Name Formatting - C/C++
本文介绍了普遍接受的变量名称格式 - C / C ++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道这可能是preference的事,但我注意到,在很多code样品我见过的变量名具有的preFIX摹_
,取值_
,米_
,或只是 _
。这是一个普遍接受的做法,而这些prefixes什么意思呢?是否有任何其他人,将是很好的了解?
I realize that this can be a matter of preference, but I have noticed that variables names in a lot of code samples I've seen have a prefix of g_
, s_
, m_
, or just _
. Is this a commonly accepted practice, and what do these prefixes mean? Are there any others that would be good to know?
推荐答案
-
摹_
是一个全局变量 -
取值_
是一个静态 -
米_
是成员(实例变量) -
_
是成员,或者更具体的私有成员(包括用法转起来)
g_
is a global variables_
is a staticm_
is a member (an instance variable)_
is either a member, or more specifically a private member (both usages turn up)-
_
,也可以用来表示一个局部变量(这个真的是没有标准) -
K
可以用来表示一个常数 _
can also be used to denote a local variable (this one really isn't "standard")k
can be used to denote a constant
这是常见的,以至于很多开发人员了解它,虽然它不是(据我所知)普遍接受。我不认为你缺少任何人。
This is common enough that many developers know about it, although it is not (to my knowledge) universally accepted. I don't think you are missing any others.
更新:更好的能见度低于整合意见
Update: Integrating comments below for better visibility
这篇关于普遍接受的变量名称格式 - C / C ++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文