typedef struct LinkedListItem
{
int Number;
LinkedListItem* Next;
LinkedListItem(int number)
{
Number = number;
Next = NULL;
}
} LinkedListItem;
LinkedListItem *head = NULL;
head = new LinkedListItem(1);
head->Next = new LinkedListItem(2); //confusing
head->Next->Next = new LinkedListItem(3); //confusing
Hello. I am a beginner learning about linked list. This is a piece of code I found. I understand everything up until the lines I marked above. I understand that the head pointer is set to NULL first so then it can later point to a new LinkedListItem.
for
head->Next = new LinkedListItem(2)
Can someone explain what is happening here? I know that the arrow means to dereference. My guess is that dereferencing Next?