Possible Duplicate:
In C, what is the correct syntax for declaring pointers?
In C++ What is the difference between:
int* a;
and
int *a;
Is it same?
Possible Duplicate:
In C, what is the correct syntax for declaring pointers?
In C++ What is the difference between:
int* a;
and
int *a;
Is it same?
Yes. Those two constructs are identical. int *a;
is more C style, because it is consistent with the "declaration follows use" rule in C. This rule means that you can read *a
, and know that it gives you an int
.
In C++, types get used on their own more often, so int* a;
is more typical, as it puts the emphasis on they type being int*
. Conformance to "declaration follows use" is less important in C++, because does not work everywhere anyway (it doesn't work with references, for example).
Note that if you write int* a, b;
(which is the same as int *a, b;
), then only a
is a pointer.