I am creating a linked list which links a struct of data together. However, this is my problem, if I declare struct Node first then the Event type wont exist, but if I declare struct Event first then nodePtr wont exist....im kinda stuck here as to how I should declare them.

struct Event
{
       void addEvent();
       
       tm startTime, endTime;
       string eventItem;
       string eventNotes;
       char allDay;
       nodePtr head, tail;
                     
};


struct Node
{
       Event eventNode;
       Node *next;
};

typedef Node* nodePtr;

Not sure of what you want to accomplish here. This piece of info might help getting the same results using a different method.

ok what im trying to do have a list of Events (which are actually a struct type containning data such as time date etc). And my problem as can be seen above is that I do not know how to resolve their declarations. I cant declare struct Event first because it contains pointers to the next Event struct. And I cant declare struct Node first because the node is of Event type.

struct Event
{
       void addEvent();
       
       tm startTime, endTime;
       string eventItem;
       string eventNotes;
       char allDay;
       nodePtr *head, *tail; //-- a pointer!, maybe...
                     
};


struct Node
{
       Event *eventNode; //-- a pointer!, maybe.
       Node *next;
};

typedef Node* nodePtr;

Maybe, you confused the functionality of Event struct and Node struct.

There are two ways to reach you objective.
First,

struct EventNode
{
  tm startTime, endTime;
  string eventItem;
  string eventNotes;
  char allDay;
  
  EventNode* next;
};

struct EventList
{
  void addEvent();
  ... // other member functions used to sustain the list 
private:
  EventNode* head;
  EventNode* tail;
};

another way use the list of STL to store the event.

struct Event
{
  tm startTime, endTime;
  string eventItem;
  string eventNotes;
  char allDay;
};

std::list<Event> eventList;
This article has been dead for over six months. Start a new discussion instead.