Simple linked list in C++
问题 I am about to create a linked that can insert and display until now: struct Node { int x; Node *next; }; This is my initialisation function which only will be called for the first Node : void initNode(struct Node *head, int n){ head->x = n; head->next = NULL; } To add the Node , and I think the reason why my linked list isn't working correct is in this function: void addNode(struct Node *head, int n){ struct Node *NewNode = new Node; NewNode-> x = n; NewNode -> next = head; head = NewNode; }