I'm completely new to C++ and am breaking my head over a simple problem. I am trying to implement a simple linked list with three nodes. Here is my code:
#include<iostream> using namespace std; struct node(){ int data; struct node* next; }; struct node* BuildOneTwoThree() { struct node* head = NULL; struct node* second = NULL; struct node* third = NULL; head = new node; second = new node; third = new node; head->data = 1; head->next = second; second->data = 2; second->next = third; third->data = 3; third->next = NULL; return head; }; The question obviously being, why does it not compile? :(
Thank you in advance for any help!
abusing namespace std;from your mind right now while you still have a chance, and never use it again.std::listinstead of creating your own.