What does "->" do in
We're learning about Link lists and I was just wondering what this does exactly.
It dereferences a pointer and accesses one of its members in one step.
It's like a combination of the * and . operators.
1 2 3 4 5 6 7 8 9 10 11 12 13
|
struct MyStruct
{
int member;
};
MyStruct* ptr = new MyStruct;
// this...
ptr->member = 5;
// is the same as saying this...
(*ptr).member = 5;
|
Thanks!
Topic archived. No new replies allowed.