PDA

Click to See Complete Forum and Search --> : What does this sign do?


knugen
Jun 3rd, 2001, 05:50 AM
I've looked in some gamecode and I don't understand what this sign does: test->test2. What does the '->' sign do exactly?

parksie
Jun 3rd, 2001, 07:25 AM
It's the indirect-access operator. For example:
struct mystruct {
int y;
int x;
};

mystruct str;
mystruct *ptr = &str; // Get pointer to str

int num = ptr->y;
int snd = str.x;

So, it's basically: pointer->member, and is equivalent to (*ptr).member. It's to make it more readable, because rather than:
(*((*ptr).ptrmember)).member you can use ptr->ptrmember->member.