Linked List of struct
Please support our C++ advertiser: Programming Forums
![]() |
•
•
Posts: 66
Reputation:
Solved Threads: 0
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;•
•
Posts: 66
Reputation:
Solved Threads: 0
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.
c++ Syntax (Toggle Plain Text)
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;
•
•
Posts: 42
Reputation:
Solved Threads: 6
Maybe, you confused the functionality of Event struct and Node struct.
There are two ways to reach you objective.
First,
another way use the list of STL to store the event.
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;![]() |
Similar Threads
Other Threads in the C++ Forum
- Removing an item from head of linked list (C)
- text file to linked list (C++)
- Linked List (C++)
- linked list problem!!! (C)
- linked list..quick question (Java)
- recursive linked list (C++)
- Adding to linked list from external file (C)
- I need help with a linked list program (C++)
- printing a linked list (C++)
Other Threads in the C++ Forum
- Previous Thread: Homework Function Compile Errors
- Next Thread: flashing characters (without clearing the screen)
•
•
•
•
Views: 874 | Replies: 5 | Currently Viewing: 1 (0 members and 1 guests)





Linear Mode