Pointers and Linked Lists

Hi all,

I'm sure this is a pretty basic concept to everyone but I'm having trouble in my Data Structures class bc I just don't understand all the uses of pointers. I understand that they are a variable that holds the memory address of another variable but I'm confused on what certain things mean. For example:

first->next->data = dataVal;

What does the "->" do in the example above?

first = first->next; what does this mean?

first = new Node;
first->data = dataVal;

What does that mean/do?

Any help would be so greatly appreciated!

Thanks,
Jen
-> means you have something like this:
1
2
3
4
5
6
struct SomeClassOrStruct
{
    //...
    SomeClassOrStruct *next;
    //...
};
1
2
3
4
SomeClassOrStruct *first = something;
first->next/*blah*/
//same as:
(*first).next/*blah*/
Last edited on
Okay but what does that syntax mean specifically? I am trying to write a "delete" function in my program and am having trouble.. thanks btw.
Do you understand what this means?
(*SomePointer).SomeMember
It's exactly the same as this...
SomePointer->SomeMember
Topic archived. No new replies allowed.