how do you make your pointers?
1) type* name;
2) type *name;
3) type * name;
i use #1, i personally think it makes the most sense, since the pointer is kind of part of the type. int* myint would be a pointer to an int. i''m just really curious, how do you guys do it?
- f l u c k y p o o
- the geek inside
quote:Original post by flucknugget
1) type* name;
2) type *name;
3) type * name;
i use #1, i personally think it makes the most sense, since the pointer is kind of part of the type.
Disagree, *name shows that name is a pointer because it is connected to the variable in my opinion. I see your point, but when you declare several variables like:
int var1, var2, var3;int *var1, *var2, *var3;
How would you declare this according to your method?
int* var1, * var2, *var3; ??or you always do:int* var1;int* var2;int* var3;
Just my humble point of view.
[edited by - clabinsky on March 20, 2002 11:44:52 PM]
#1 all the way. As flucknugget said, the ''pointer'' qualifier is part of the variable''s type, not the variable''s name.
I find #2 to be misleading. It gives the appearance of dereferencing the pointer:
int *i = &p
but what''s really happening is
i = &p
I find #2 to be misleading. It gives the appearance of dereferencing the pointer:
int *i = &p
but what''s really happening is
i = &p
no clabinsky, you can just do this:
int* var1, var2, var3;
they would all be pointers. I prefer method one also, because of this. Also in my head when I read this I read "integer pointer called var1" not "var1 is a pointer to an integer"
just the way I like it I guess
-Pac
int* var1, var2, var3;
they would all be pointers. I prefer method one also, because of this. Also in my head when I read this I read "integer pointer called var1" not "var1 is a pointer to an integer"
just the way I like it I guess
-Pac
quote:Original post by Pactuul
they would all be pointers
Actually, only the first one would be a pointer.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement