well I usually do my variables (within a class) one per line but not the way adrianxw means. It's more like this:
Code:class Blah
{
public:
int
m_x,
m_y,
m_z;
char
*m_ptr,
m_str[256],
m_singlechar;
}
Printable View
well I usually do my variables (within a class) one per line but not the way adrianxw means. It's more like this:
Code:class Blah
{
public:
int
m_x,
m_y,
m_z;
char
*m_ptr,
m_str[256],
m_singlechar;
}
Am I the only one that uses?????Code:type * pVar;
>>Am I the only one that uses
Yes - because nobody liks hungarian notation. To quote DavidP "A horse is a horse; there is no excuse for Hungarian Notation"
Anyhow, I always use char *whatever. It's just how I learned it...I don't see the value in changing the way I do it if it's all aesthetics.
There's no need for hungarian notation in a type-safe language like C++Quote:
Originally posted by Krak
Am I the only one that uses?????Code:type * pVar;
It may have had a small place in C, but certainly not C++
>>>
To quote DavidP "A horse is a horse; there is no excuse for Hungarian Notation"
<<<
A "horse" is actually an "orse" handle... ;)
I believe there is a difference between Hungarian notation and calling pointers pSomething.
The full Hungarian notation may have had a small use back in the dim and distant, but with todays IDE's, if I am unsure what something is declared as, I put my cursor on it and the IDE tells me, and offers to show me the declaration. Hungarian notation is inexcusable obfuscation.
Frequently, however, I have an object and a pointer to the same object, Object and pObject. People will say that is Hungarian, but I would add, that I have been doing that since the late 70's, ergo, pre Hungarian, simple common sense.
I'll concede - that point hadn't crossed my mind. You're right, even I do that if I have a pointer to the same data...
>>A "horse" is actually an "orse" handle...
Speaking of which, hWhatever is also something I do quite frequently thanks to Petzold :rolleyes:
As far as I can remember, that's about as deep into notation that I go...maybe I've left something out, but I doubt that...
Oh, and every once-in-a-while I'll do the whole CClass thing...not all that often, though...
My turn to confess, yes, I do call a handle to something an hSomething, but yes, that is also as far as I go.
I just do it out of habit. When I started doing pointer crap, I just used:Quote:
Originally posted by -KEN-
>>Am I the only one that uses
Yes - because nobody liks hungarian notation. To quote DavidP "A horse is a horse; there is no excuse for Hungarian Notation"
Anyhow, I always use char *whatever. It's just how I learned it...I don't see the value in changing the way I do it if it's all aesthetics.
int * pPointer;
I just feel more comfortable with that method for some reason.
Hungarian notation? Meh. Screw that. I'm calling this "Krak Notation", since only I use it. Besides, it's not like it hurts anything.
FILE *fp;
always, i don;t feel comfortable putting it like FILE* fp; it just feels wierd!
char *pVar; actually... I learned it that way, and since I never declare multiple pointers on the same line or grouped, theres never confusion.
>>... and one declaration per line - no confusion.
Dito. Inside classes I will often group simular data such as FillYourBrain demonstrates:
As for pVar: Always. I always identify pointers (for all the same reasons that have already been presented).Code:int
x,
y,
z;
I use it because my data types won't associate with the lowly *, so it has to hang with my identifiers. Poor little guy, nobody ever considers how the operators feel, it's all about data types. My identifiers are cooler anyway, so the * is happier with them than with the cliquish data types :-)Code:char *var;
>My turn to confess, yes, I do call a handle to something an hSomething, but yes, that is also as far as I go.
i for some reason, always prefix bools with b
bool bThis, bThat;
Well, if we're all confessing our dirty little habits... My BOOLs are always fully uppercase. It just seems weird any other way. BOOL, TRUE, FALSE... It just works. *shrug* Though possibly I prefix by 'Is': IsCOMPLETE, etc.
but isn't that a little ugly? i only cap my defines, and i always suffix my typedefs with '_t'.
and how's this for retarded!!!! i always prefix my enum type names with enum_ haha!!
>>but isn't that a little ugly? i only cap my defines
I also cap my defines (in 99% of cases. There have been times when lowercase defines became appropriate). But an uppercase BOOL only seems right.
BOOL IsComplete = TRUE;
BOOL IsCOMPLETE = TRUE;
It actually came to pass when I was writing some code for an older application and came across the rather unsual problem of strange results traced to passing a BOOL pointer to a function that accepted a bool pointer. The difference was not immediatly obvious, and it caused some confusion before realising that a BOOL is actually a 32-bit type. So I started differentiating my newly implemented BOOL variables by making them uppercase to avoid confusion when comparing them to the existing bools. The project was large and I got rather used to it...