linked lists

This is a discussion on linked lists within the C++ Programming forums, part of the General Programming Boards category; how do u walk through a linked list? i've read and don't understand how do do so....

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    109

    linked lists

    how do u walk through a linked list? i've read and don't understand how do do so.

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    Quote Originally Posted by DarkDot View Post
    how do u walk through a linked list? i've read and don't understand how do do so.
    Perhaps post exactly what it is you are looking at and what you are finding difficult.

    Otherwise it is really hard to read your mind as to what you don't understand. And it is quite likely that without providing further details you will simply be pointed to somewhere that has pretty much the same thing that you were having a difficult time reading.
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Mar 2007
    Posts
    109
    ok what i need to know how to do is using nodes add a node to the end of the list. But the values i will be adding to the end of the list need to be read from the another linked list which is why i also need to know how to walk through a list. Thats a singly linked list.

  4. #4
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,006
    http://faq.cprogramming.com/cgi-bin/...&id=1073086407

    Note "Traverse".

    [edit]Depending on how you have set up your list, this may apply.
    Code:
    for ( item = list; item != NULL; item = item->next )
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  5. #5
    Registered User
    Join Date
    Mar 2007
    Posts
    109
    thannks that answered that question, my next one in a doubly linked list how would i define a constructor that takes argumenst tha allow a node to be immediately lined into a list. i have
    Code:
    DLListNode(const T&, DLListNode<T>*,DLListNode<T>*)
    it doesn't seem right and also how would i define in the header file for a doubly linked list node member fuction to set and retrieve private data member values? i feel like the constructor is what that is for.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Singly Linked Lists: Clarification Needed
    By jedispy in forum C++ Programming
    Replies: 4
    Last Post: 12-14-2006, 05:30 PM
  2. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 05:32 PM
  3. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 11:32 PM
  4. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 09:57 PM
  5. doubly linked lists
    By qwertiop in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2001, 07:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21