As the title states, what is the difference between -> and . I thought they were the same thing?
These are different operators, though related.
. is field selection, and
-> combines pointer dereference and field selection. So
a->b is equivalent to
(*a).b or more correctly
Many languages don't have both
->. In C# and Java, for example, which don't have
. operator does both dereference and field selection as in
-> in C. However, in C# and Java,
. also does selection from a namespace, which does not involve dereferencing (more like C++'s
Note: C# does have an
unsafe construct that allows for unsafe/raw pointers, and also does actually have the
-> operator to work with them. However, you won't encounter
-> unless you're working in