Do you really want the compiler to figure it out on your own? If so, then the following will evaluate the same thing (assuming p is a pointer to a structure with an element x ):
(*p).x; px
If dereferencing a pointer here is implicit, should it be implicit everywhere? Consider:
int* p; int i = p;
I think that would be much more confusing than having two separate statements.
It is also useful to have two operators to keep track of how many layers of indirection you have. Of course, the operator -> not needed for this, since p->x equivalent to (*p).x , but it makes the code more understandable and understandable.
James McNellis
source share