Hungarian notation
for C/C++/Java variable names

syntax

[scope]_<types><NameString>
    example: g_pszVarName

key

scope
notation description
g_global
m_member (of a class, usually)
use neither for local variables

types
notation description
aarray
bBOOL or boolean
chchar
dwdword
ffloat
fnFunction.
hHANDLE (WinAPI)
hwndHWND (WinAPI)
iint
llong
nalso int
pPointer.
pvVoid pointer.
ptPOINT struct (WinAPI)
r or rcRECT struct (WinAPI)
sstruct
szNull-terminated string (stands for string, zero terminated).
wword

Examples

g_pszVarName
global pointer to a null-terminated string named VarName
apfValues
local array of pointers to floats named Values
pafValues
local pointer to an array of floats named Vaues
m_hwndParent
member HWND named Parent

Custom types

This works well for all the primitive types, but what about when you make your own typedef struct or class?

In cases like this, I just wing it and do whatever seems logical at the moment:

For instance, if we have a class ListIterator, an instance of that class could be ListIterator *pliIterator (local pointer to a ListIterator object named Iterator).

 

Note: I built this page off the top of my head based on what I use all the time. Other people go by different hungarian notation rules.
If something is blatantly wrong, send me an email and I'll fix it.


This site was last built on 8/10/98; 5:39:28 PM with 5.0.2b20. Internet service provided by JavaNet. Mail to: dmorelli@ct1.nai.net. This site is currently being built on Windows 95