views:

39

answers:

3

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? ie: mData -> Matrix (array) of Data pData -> pointer to Data uiData -> unsigned int Data etc...

Is this correct? Thanks all!

A: 
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.

Amardeep
Is it really really popular to use this?
Russel
I'd say it is common but losing popularity. Modern editing environments mitigate the need to do this.
Amardeep
A: 

Yes you are in a way correct

This link provides you more details on the Hungarian notation http://en.wikipedia.org/wiki/Hungarian_notation

ckv
+1  A: 

This is generally known as Hungarian notation.

There's nothing ironclad about the prefixes - they may vary among languages and platforms and programming shops.

And yes, your interpretations are probably correct - p and ui are common, and you'd have to check to see that m really is referring to Matrix in your environment, although it may refer to a class member.

brainjam