Sign in to follow this  

- what is this...???

This topic is 3729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok working on a little sprite animation in allegro for the first time. Acording to my reading material i have to build my own data structures to simulate my own animations. Ok here's the part i don't know. In the sample code the use this symbol: -> OK I know for a fact this already looks like a total noob quest on my part but what does this do exaclty? Also can i change the direction? <- thanks in advance!

Share this post


Link to post
Share on other sites
operator-> is used to access members through a pointer:


class obj
{
public:
int member;
}

int main()
{
obj *object = new obj();
//access member of object
object->member = 1;
delete object;
return 0;
}





Similarly, you could dereference the pointer and use operator.:
(*object).member = 1;

And no, <- is not a valid operator.

Further reading.

Share this post


Link to post
Share on other sites
"->" Is use to access an element of a class or struct via a pointer.

For example:


struct foo{
int a;
};

...

foo* f = new foo;

// You can write:
foo->a = 10;
// Or you can write:
(*foo).a = 10;




And to your second question, no you cannot reverse the arrow.

Share this post


Link to post
Share on other sites

This topic is 3729 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this