I am doing Box2D programming, and heads up, I am a total noob to C++ and C. I am an Objective-C guy, and that is why it is becoming really hard for me to understand the language. Especially:
->
Basically I understand that this is used for referencing different methods or functions or variables/properties like below:
body->GetWorld()->DestroyBody(body);
So is this equivalent to dot notation in Objective-C:
// made up example
[body.world destroyBody];
or
[self destroyBody:body.world];
Or something similar? I really don’t understand this. Can someone give me a heads up on what this is. Thanks!
I don’t know Objective-C, but I can explain difference between
->and.in C and C++, hope that helps..is operator that allows you to access member of struct/class instance.a->bis the same as(*a).b– so it first dereferences the pointer, then accesses member of instance that the pointer was pointing to.Also, there is a case that Luchian has mentioned – overloading of
operator->()of given class. In case when class you are using does overload this operator, the behavior will be different, defined by the class – it can return virtually everything it wants.