how do I do a Linked List ?!

This is a discussion on how do I do a Linked List ?! within the C++ Programming forums, part of the General Programming Boards category; Hello all, I am new to C++ and I wish to do a linked list. Does C++ not have a ...

  1. #1
    Unregistered
    Guest

    Angry how do I do a Linked List ?!

    Hello all,

    I am new to C++ and I wish to do a linked list. Does C++ not have a built in library function for linked lists which means I don't have to create a list class ??

    I have tried the following code, which just gives the error List undeclared.

    #include <iostream.h>
    #include <stdlib.h>

    int main()
    {
    List<int> list;
    int ix;

    for (ix = 0; ix < 10; ix++) list.append(ix);

    ListIterator<int> iter(list);
    while (!iter.terminate()) {
    printf("%d ", iter.current());
    iter.succ();
    }
    puts("");
    system("PAUSE");
    return 0;
    }


    Can someone point me in the right direction to achieve a linked list, I wish to do it with Objects (I assume this is OK?).

    Thanks in advance
    L

  2. #2
    zen
    zen is offline
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    You'll have to include the <list> header, and it's list not List. Check the SGI site for a STL guide if you're not sure.
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ Linked list program need help !!!
    By dcoll025 in forum C++ Programming
    Replies: 1
    Last Post: 04-20-2009, 10:03 AM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 10:10 AM
  3. Reverse function for linked list
    By Brigs76 in forum C++ Programming
    Replies: 1
    Last Post: 10-25-2006, 10:01 AM
  4. Template Class for Linked List
    By pecymanski in forum C++ Programming
    Replies: 2
    Last Post: 12-04-2001, 08:07 PM
  5. singly linked list
    By clarinetster in forum C Programming
    Replies: 2
    Last Post: 08-26-2001, 10:21 PM

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