| | |
Linked List of struct
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jan 2008
Posts: 77
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.
C++ Syntax (Toggle Plain Text)
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;
•
•
Join Date: Jan 2008
Posts: 77
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;
•
•
Join Date: Mar 2008
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,
C++ Syntax (Toggle Plain Text)
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.
C++ Syntax (Toggle Plain Text)
struct Event { tm startTime, endTime; string eventItem; string eventNotes; char allDay; }; std::list<Event> eventList;
![]() |
Similar Threads
- 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)
| Thread Tools | Search this Thread |
api array arrays beginner binary bitmap c++ c/c++ calculator char class classes code coding compile compiler console conversion convert count data database delete desktop developer directshow dll download dynamic encryption error file forms fstream function functions game generator getline givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory news node number output parameter pointer problem program programming project proxy python random read recursion recursive return string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





