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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 anint.In C++, types get used on their own more often, so
int* a;is more typical, as it puts the emphasis on they type beingint*. 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 asint *a, b;), then onlyais a pointer.