I've recently picked C++ up again to attempt to learn it on my own as I don't have the time presently to go to a proper class. This time around my comprehension has been much better, however, I'm a bit confused with the '->' notation in relation to "Pointers to Classes."
I'm currently reading Chapter 10 - Data Structures and Classes of the book "Introduction to Game Programming with C++" by Alan Thorn. As I run into topics I don't understand from one book I switch to another and read the same topic to see if another perspective helps me understand it better. In the case of "Pointers to Classes" I'm still just not wrapping my head around it.
Here is the example the book offers:
Frog *Pointer_To_Frog = &frog;
When I look at this I see an instance of the class "Frog" is being created and being named "frog." On the next line a pointer of the datatype "Frog" class is created and assigned the memory location for the instance "frog." This brings me to the line I don't fully understand. The way I see it is the function or method 'eat' of the instance 'frog' is being called. So why isn't the syntax just 'frog.eat();'? Unless the purpose of the example is to show how to get the memory location of the function 'eat();' using the pointer, in which case shouldn't the syntax be something like '*Pointer_To_Frog->eat();'? Or even '*Pointer_To_Frog->frog.eat'?
Anybody see how I'm misunderstanding this? Perhaps a clearer example would make more sense I know the whole Class "Frog" instance "frog" can easily be erroneously interchanged.