What does "->" do in

Oct 1, 2011 at 7:09pm
We're learning about Link lists and I was just wondering what this does exactly.
Oct 1, 2011 at 7:18pm
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;

Oct 1, 2011 at 9:06pm
Thanks!
Topic archived. No new replies allowed.