For example, int *p=& a;
should be written with * and p as a whole, such as continuous definition: int *p1, *p2, *p3;
But the actual meaning should be int and * together, representing a pointer type, the full format is: int* p; p=& a;
Why do we define * and p as a whole? Am I always confusing pointer definitions with pointer addresses, or am I just getting it wrong?
0 Answer
Both int* p and int* p are valid, but int* p is misleading. In this case, the type of p1 is int , and the type of p2 is int. However, since and int are written together, it is easy to misunderstand that the type of p2 is also int*. By writing int* p1, p2 will not be misunderstood.
这家伙很懒,什么都没留下...