[Solved] Why is p2 not a pointer type in declaration int* p1, p2;? [duplicate]


The simple answer that won’t help you much is that this is done for backwards compatibility with C, that has exactly the same syntax to define variables. The rationale for that design would have to come from the creators of C, and I don’t really know it.

What I do know is that most coding guidelines I have used in different companies prohibited the definition of multiple variables in the same statement, and once you avoid that, everything becomes simple to read an maintain. The syntax for declarations in C and C++ is not really one of their strengths, but it is what it is.

solved Why is p2 not a pointer type in declaration int* p1, p2;? [duplicate]