The C++ LINKED LIST

Reply

Join Date: Jan 2006
Posts: 3
Reputation: Twins_effect is an unknown quantity at this point 
Solved Threads: 0
Twins_effect Twins_effect is offline Offline
Newbie Poster

The C++ LINKED LIST

 
0
  #1
Jan 13th, 2006
hey guys, im a new guy here in the forum and im also an IT student who gets into C++ troubles most of the time, but enough about that... i just wanna ask if anyone can help me in my linked list problem, i think its about pointers and address. like a->link, well thats what it looked like. Problem is i dont understand a thing and my prof wont even give me an example, i dont even get the slightest idea of what's it all about and i dont know where to start, SO CAN ANYONE PLS SHOW ME AN EXAMPLE,even just the basic ones THANKS!!!
^_^
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 5,264
Reputation: iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold iamthwee is a splendid one to behold 
Solved Threads: 376
Featured Poster
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Posting Expert

Re: The C++ LINKED LIST

 
0
  #2
Jan 13th, 2006
try google + "linked lists"
*Voted best profile in the world*
Reply With Quote Quick reply to this message  
Join Date: Dec 2005
Posts: 43
Reputation: Nedals is an unknown quantity at this point 
Solved Threads: 0
Nedals Nedals is offline Offline
Light Poster

Re: The C++ LINKED LIST

 
0
  #3
Jan 14th, 2006
Linked list are typically used to work with data structures.
Access to items in the list is controlled by pointers.

This is a very simple example to construct a linked list. You will need to do a lot more reading to use them correctly.

One thing to remember:
You must delete all the list items when exiting the program otherwise you will create a memory leak.
  1. struct dataRec {
  2. type data;
  3. dataRec *next;
  4. }
  5.  
  6. dataRec *prList = NULL; // the list anchor
  7.  
  8. function addRecord(dataRec *prList) {
  9. dataRec *temp = new dataRec; // create a new record to add to list
  10. temp->data = whatever;
  11. temp->next = NULL;
  12.  
  13. // Now add this record to the end of the list
  14. dataRec *curr = prList;
  15. if (curr == NULL) { // the list is empty
  16. prList = temp; // prList, the anchor, now points to the first record
  17. }
  18. else {
  19. if (curr->next == NULL) { // last record in list
  20. curr->next = temp; // add temp to end of list
  21. }
  22. else { // move up the list until the last entry
  23. curr = curr->next;
  24. }
  25. }
  26. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2006
Posts: 3
Reputation: Twins_effect is an unknown quantity at this point 
Solved Threads: 0
Twins_effect Twins_effect is offline Offline
Newbie Poster

Re: The C++ LINKED LIST

 
0
  #4
Jan 15th, 2006
thanks, i really appreciate it! i think i'll do some head crackinh for awhile to master this ^^
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC