linked list question

This is a discussion on linked list question within the C++ Programming forums, part of the General Programming Boards category; I was looking for help in a linked list problem I am having in C++. I wanted to create a ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    1

    Exclamation linked list question

    I was looking for help in a linked list problem I am having in C++. I wanted to create a linked list that contains a node that references a dataObject and also references another linked list. This allows for a a linked list that can extend infinitely at every node. Does anyone
    have any sugestions or source code that pertains to this- or even another datastucture that can serve the same purpose.

    My problem with coding it is, that my linked list includes a node which includes a dataobject and another linkedlist(itself). This gives me an error. There must be a way around this.

    Steve

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    a list can be an object just like any other. The implementation of the algorhythm you are proposing sounds like a list of lists, so yeah I think it is possible, but it might not be straightforward, and I've never tried it.

  3. #3
    Registered User
    Join Date
    Nov 2001
    Posts
    24
    make a array of pointers (Ex: int **array then allocate the pointer (Ex: array=new int*[7] this will make a array of pointers to a array of pointers(i hope you understand its a tuff subject) you dont have to use the "7" it could be a varable taken from the user. the you need to make the arrays that the pointer arry points to like this:
    {
    Code:
    for(int i=0;i<7;i++)
    	array[i]=new int[5];
    this will make the 7 array point to a array of 5. I think you can make it a linked list instead of the array 5 youll have to play with that. hope this helps. Good luck.

    Skeptic

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Linked List Not Saving Value as Int
    By bar338 in forum C Programming
    Replies: 4
    Last Post: 05-04-2009, 08:53 PM
  2. linked list question
    By brb9412 in forum C Programming
    Replies: 16
    Last Post: 01-04-2009, 04:05 PM
  3. singly linked circular list
    By DarkDot in forum C++ Programming
    Replies: 0
    Last Post: 04-24-2007, 09:55 PM
  4. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 11:21 PM

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