Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

flucknugget

how do you make your pointers?

This topic is 5939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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]

Share this post


Link to post
Share on other sites
#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;

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
What''s wrong with:

int* var1, var2, var3;

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
2nd method. You 1st method guys are all crazy

Share this post


Link to post
Share on other sites
quote:
Original post by Pactuul
they would all be pointers

Actually, only the first one would be a pointer.

Share this post


Link to post
Share on other sites

This topic is 5939 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Guest
This topic is now closed to further replies.

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!