The posts What can I use instead of the arrow operator, `->`? and Arrow operator (->) usage in C state
The following two expressions are equivalent:
x->y (*x).y
But this does not appear to always be true when taken as a mathematical equivalence.
Why does g++ throw an error when replacing
a->b->c
with
a->(*b).c
?
It seems the above equivalence is not always replaceable. Therefore, I think the term "equivalent" is a bit misleading.
Also, I am not referring to any sort of overloading in this question.
You've got the associativity rules wrong. a->b->c
is (a->b)->c
, not a->(b->c)
, so it becomes (*(a->b)).c
(and then (*((*a).b)).c
).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With