Reputation: 762
Easy question for you vets out there:
What is the accepted (assuming there is one...) prefix for a CString variable name? For clarification, I've seen the following for other data types:
int iIndex; //integer
int* pIndex; //pointer
bool fFlag; //bool flag
And there are countless others. Please feel free to let me know if this is really a non-question or something with a "Whatever you want" answer.
Upvotes: 1
Views: 1219
Reputation: 103535
Prefixes such as those are an abuse of the concept of Hungarian Notation.
The idea of HN is that a variable is prefixed with a code describing its use. e.g., a variable holding the count of something would be prefixed cnt
; a variable holding an index would be prefixed inx
. A variable holding a flag would be prefixed f
. A variable holding a number (that wasn't a count or an index or something else common) would be prefixed n
.
However, soon people got lazy, (and largely due to that last example) and the prefixes started to be just an indication of the data type. This has some use in C, where the declaration of a variable had to be at the top of the function, potentially some distance from where it is used. (especially when code was written in a simple text editor)
But, eventually, we got more type safe languages, and better IDEs, so the faux-Hungarian Notation because unnecessary and scorned.
Upvotes: 3
Reputation: 1741
I've seen "s" used. Example: sIndexname.
I use "m" for a data member: mIndex, and "p" for a pointer to a data member: mpIndex. I only use them for class-scope variables. That's it.
By today’s "standards" even that is pushing it. AFAIK, except for a few Microsoft diehards Hungarian notation is dead. I am especially amused when I see it used for local variables that are used exactly once 2 lines later. Fun.
For some reason I am repulsed by the "m_" convention. It's just ugly, imo. :-)
Upvotes: 1
Reputation: 35580
There is none. Never prefix a variable with its type. See Making Wrong Code Look Wrong for the correct use of prefixes.
Upvotes: 3
Reputation: 2474
There is no standard for notation in a variable name. In fact, with better development environments (with intellisense, etc.) it is highly unnecessary.
Upvotes: 1