I use int * p;.
It looks good at my eyes, and, I HEARD (Not sure) this is the best way.
But probably there's no difference between any of those "notations".
Choose a single standard and stick with it in your project. It doesn't really matter which one you choose or why it's been chosen as someone else will have the standard imposed on them.
I must admit that I like to use int * p;. My thinking; * is a pointer operator not a type, so it does not belong with the type specifier and it is not part of the name.
Then when you get to int X::* ptr... (pointer to a member of X of type int), it is still consistent
@vlad
You keep bringing up the same argument time after time. From this thread it is clear that many people that write int* p; (me included) only do one declaration per line so what you say is never a problem. Please accept that people do things in different ways and it's not necessary bad just because it differs from how you do it.
@Cubbi
Write a letter to Microsoft about this bad style.::)
First of all classes can have no names so you can not write
typedef A MyClass;
typedef A* PMyClass;
Secomdly it is a bad style because I do not see what is MyClass and what are its members. The name of the type is separated from its definition. So then you meet such declaration you should spend a time to find its definition.:)
All what you are doing is to make the live of programmers harder. :)
and do not forget that such declarations are very many in system headers as for example for Windows API.
The Windows API is a C interface. And in C, structs go in their own namespace. So it is common and convenient to make a typedef, and why you're there, define some related types too. So yes:
So yes:
typedef struct _OVERLAPPED {
//...
} OVERLAPPED, *LPOVERLAPPED;
is common, but that has nothing to do with C++ and I'd go as far to say you're wrong to do that in C++, it's way beyond bad style.
First of all these words ""t's way beyond bad style" have no any sense. It is only your emotions based on incomprehension of 1) what is bad and what is good styles; 2) C and C++ code can be used in one project 3) what is a declarator in C/C++ and what is a type specifier. That is all.:)
@moorecm
This is the part that got me wondering...
Maybe this is because you do not read the C++ standard?