where to place * in pointer type

Pages: 1234
bad style


Stopped reading here. Opinion.

Anyway, I put my *s between the type and the name of the variable.

@firedraco

Anyway, I put my *s between the type and the name of the variable.


I use this style then I want align vertically several declarations that contain pointers and ordinary objects. For example

1
2
3
4
int   a;
int * p;
int   b;
int * p1;


But for example function's parameter I declare as

void f( int *a, int *b );
Last edited on
Well yeah, that's were it goes (between).
void *foo() is kind of misleading at first glance. Looks like it is a void function, but it's really a void* function.

void* foo() makes more sense here.
That there will not be a misleading use with functions the following syntax

void * foo();
closed account (zb0S216C)
It doesn't matter where the asterisk appears, so long as it's there:

 
int                                              *                            ptr_(nullptr);

It's still a pointer declaration, and the compiler couldn't give two f***s. But for me, it depends:

1
2
typedef int* int_ptr_;
int *ptr_; 

See, the asterisk is in different places, but the positioning of the asterisk matters not.

Wazzak
Last edited on
Topic archived. No new replies allowed.
Pages: 1234