Okay to explain it in a more complete way. The most other guys had already wrote that you have to use ‘->’ when ever you have a pointer. But you could also do this with ‘.’, to do this you must respect the priority of the operators. We need the ‘*’ to get the content of the pointer, but this has a lower priority than the ‘.’, so you must write it into brackets to give it a higher priority, so when you want to do this with a ‘.’ you have to wrote:
(*sample).next
and you see this is a complex syntax, to do this in a more easy way the ‘->’ was introduced. With it you could write code in a more comfortable way.
So this is is equal to the example and it looks much better.
sample->next
solved About struct and pointer in C++ [duplicate]