Justin's Words

匈牙利表示法(Hungarian Notation)

对变量命名有很大帮助,来自 Learn Cpp.Com

The type prefix indicates the data type of the variable.



























































Type prefixMeaningExample
bbooleanbool bHasEffect;
c (or none*)classCreature cMonster;
chchar (used as a char)char chLetterGrade;
ddouble, long doubledouble dPi;
eenumColor eColor;
ffloatfloat fPercent;
nshort, int, long
char used as an integer
int nValue;
sstructRectangle sRect;
strC++ stringstd::string strName;
szNull-terminated stringchar szName[20];

The following type modifiers are placed before the prefix if they apply:


































Type modifierMeaningExample
aarray on stackint anValue[10];
ppointerint pnValue;
padynamic arrayint panValue = new int[10];
rreferenceint rnValue;
uunsignedunsigned int unValue;

The following scope modifiers are placed before the type modifier if they apply:























Scope modifierMeaningExample
g_global variableint g_nGlobalValue;
m_member of classint m_nMemberValue;
s_static member of classint s_nValue;