Pointer dereference operator ( (*) vs -> )

As “jamesdlin” already noted, the * and -> operators can be overloaded for class types.

And then the two expressions (*ptr).method() and ptr->method() can have different effect.

However, for the built-in operators the two expressions are equivalent.

The -> operator is more convenient when you’re following a chain of pointers, because . has higher precedence than *, thus requiring a lot of ungrokkable parentheses.

Consider:

pBook->author->snailMail->zip

versus

(*(*(*pBook).author).snailMail).zip

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)