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!
Remove the “()” from the struct declarations. Your compiler should have told you that.