Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 446
NlightNFotis Avatar asked May 07 '26 10:05

NlightNFotis


1 Answers

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;
like image 155
Kos Avatar answered May 10 '26 02:05

Kos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!