I've looked in some gamecode and I don't understand what this sign does: test->test2. What does the '->' sign do exactly?
Printable View
I've looked in some gamecode and I don't understand what this sign does: test->test2. What does the '->' sign do exactly?
It's the indirect-access operator. For example:
So, it's basically: pointer->member, and is equivalent to (*ptr).member. It's to make it more readable, because rather than:Code:struct mystruct {
int y;
int x;
};
mystruct str;
mystruct *ptr = &str; // Get pointer to str
int num = ptr->y;
int snd = str.x;
(*((*ptr).ptrmember)).member you can use ptr->ptrmember->member.