Im an old, emphasis on old, K&R guy, so I am very well versed in accessing members of structures, unions, and now classes with "." notation vs "->" notation. I was asked this morning "why the difference?" My answer started with "That's easy," and then every instance that I could come up with I ended up deciding that a modern compiler could easily overcome the issues.
So, given a structure or class foo with a single member "a"
I understand that
struct foo *pfoo, afoo;
pfoo->a would be the appropriate call
struct foo afoo;
afoo.a would be the appropriate call
but why are they separate. In case 1, why can't the compiler sort out pfoo.a or in the second afoo->a. There must be a case where this behavior would be unacceptable, but I am trying to fathom what it is.