Search code examples
c++pointerssyntaxsemantics

Semantic difference between different pointer syntax in c++?


In C++, is this form int *p semantically different than this one int* p? Or is this clearly a matter of style?

Now this question may be dumb, but I remember that I had seen somewhere both styles being used at the same time, something that led to me to believe that there may be different semantics between those forms.


Solution

  • They're the same.

    That's tricky sometimes, since

    int* a, b;
    

    defines one pointer and one int. This style makes it more clear:

    int *a, b;