Jump to content
  • Advertisement
Sign in to follow this  
daniel_i_l

pointer question

This topic is 4415 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

Advertisement
None, but try to keep a consistent style:
int* a, b;
wont declare 2 variables of type pointer to int, but a pointer to int and an int.
You should write
int* a, *b;
to get that. But then you can as well write:
int *a, *b;

The 'problem' is that sometimes the "*" applies to the int as in casting (where you write (int*)).

Share this post


Link to post
Share on other sites
My style, no better of worse than others, but just for you to take as 1 available suggestion:


int main(void)
{
}

int* foo(int *x, int *y, int &z, const int &zee)
{
int i, j, k;
int *a;
int *b;
int *c;
}





so basically I use the (*) attaches to variable name syntax, except in the case of the function declaration there is no variable name, so I use (*) attached to return type.

I also don't declare mutliple poitners on one line unless writing an algorithm which is nothing but pointer arithmatic, even though my style is the one that would work fine if I did multi-declare. Just personal preference and habit.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!