There are two ways to "look at" variable int * a
:
- You can consider
a
as a variable of typeint*
. - You can consider
*a
as a variable of typeint
.
Hence, some people would declare int* a
, whereas others would declare int *a
.
I would like to know with regards to the two approaches above:
- What are the arguments in favor and against each one of them?
- Which one of them is generally consider a better coding convention?
The standard appears to be "discouraging" the use of the int* a
approach:
- It cannot be applied when declaring a function pointer
int (*func)(int x)
. - It cannot be applied when declaring several pointers in the same line
int *a,*b,*c
.
I've been using the int* a
approach most of my professional life.
But it turns out to be in contrast with what most people do.
Any additional insights will be highly appreciated.