Search code examples
pointersnaming-conventionsprefix

Prefixes for C/C++ data members / objects


I've been getting more and more involved in C/C++ programming lately and have noticed a trend in the way people name datatypes in their code.

I always see prefixes such as p, m, ui, etc.

For example: mPlayerNames, pData, uiNumResets

I think I get it, but just to confirm: Do these prefixes indicate the data type? i.e.:
mData -> Matrix (array) of Data
pData -> pointer to Data
uiData -> unsigned int Data
etc...

Is this correct?


Solution

  • m - member of a class
    p - pointer
    ui - unsigned int
    lpsz - long pointer string zero terminated (whew!)
    

    I personally only use the 'm' and the 'p'. The rest is just zany in my view. It makes the code so darn hard to decipher.

    I did maintenance work on this guy's code who used semi-Hungarian notation type id prefixes on every variable, function, and other identifier in the code. He used $ signs liberally to separate words. It was hard to keep the murderous rage in check.