开发者

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开发者_StackOverflow 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?


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.


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.


Yes you are in a way correct

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜