对变量命名有很大帮助,来自 Learn Cpp.Com。
The type prefix indicates the data type of the variable.
Type prefix | Meaning | Example |
---|---|---|
b | boolean | bool bHasEffect; |
c (or none*) | class | Creature cMonster; |
ch | char (used as a char) | char chLetterGrade; |
d | double, long double | double dPi; |
e | enum | Color eColor; |
f | float | float fPercent; |
n | short, int, long char used as an integer | int nValue; |
s | struct | Rectangle sRect; |
str | C++ string | std::string strName; |
sz | Null-terminated string | char szName[20]; |
The following type modifiers are placed before the prefix if they apply:
Type modifier | Meaning | Example |
---|---|---|
a | array on stack | int anValue[10]; |
p | pointer | int pnValue; |
pa | dynamic array | int panValue = new int[10]; |
r | reference | int rnValue; |
u | unsigned | unsigned int unValue; |
The following scope modifiers are placed before the type modifier if they apply:
Scope modifier | Meaning | Example |
---|---|---|
g_ | global variable | int g_nGlobalValue; |
m_ | member of class | int m_nMemberValue; |
s_ | static member of class | int s_nValue; |