Commonly Accepted Variable Name Formatting - C/C++
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 variable
- s_ is a static
- m_ is a member (an instance variable)
- _ is either a member, or more specifically a private member (both usages turn up)
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
- _ can also be used to denote a local variable (this one really isn't "standard")
- k can be used to denote a constant