Linked Lists

This is a discussion on Linked Lists within the C++ Programming forums, part of the General Programming Boards category; I create a linked lists and get three errors: Code: Error E2176 C:\linkedlist.cpp 10: Too many types in declaration Error ...

  1. #1
    Registered User
    Join Date
    Jul 2004
    Posts
    60

    Linked Lists

    I create a linked lists and get three errors:
    Code:
    Error E2176 C:\linkedlist.cpp 10: Too many types in declaration
    Error E2111 C:\linkedlist.cpp 11: Type 'linkedlist' may not be defined here
    Error E2034 C:\linkedlist.cpp 27: Cannot convert 'int' to 'linkedlist' in function main()
    here is my code:
    Code:
    #include<iostream>
    #include<string>
    #include<conio>
    using namespace std;
    struct linkedlist
    {
    string key;
    linkedlist *next;
    }
    int main()
    {
    linkedlist *first = NULL, *second = NULL, *third = NULL, *fourth = NULL;
    first = new linkedlist;
    first->key = "Hello, ";
    second = new linkedlist;
    first->next = second;
    second->key="my ";
    third = new linkedlist;
    second->next=third;
    third->key="name's";
    fourth = new linkedlist;
    fourth->key=" Joe!";
    fourth->next=NULL;
    cout<<first->key<<second->key<<third->key<<fourth->key;
    cout.flush();
    getch();
    return 0;
    }
    Child who knows C++
    Using Borland C/C++ Compiler 5.5 (Command Line Version)

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    Put a semi-colon after the closing brace '}' of your struct.

  3. #3
    Registered User
    Join Date
    Jul 2004
    Posts
    60
    It worked! Stupid me on that structure I didn't put a semicolon.
    Child who knows C++
    Using Borland C/C++ Compiler 5.5 (Command Line Version)

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, 04:30 PM
  2. Linked Lists 101
    By The Brain in forum C++ Programming
    Replies: 5
    Last Post: 07-24-2004, 04:32 PM
  3. Map file formats and linked lists
    By Spitball in forum Game Programming
    Replies: 2
    Last Post: 03-04-2004, 10:32 PM
  4. need help w/ linked lists
    By MKashlev in forum C++ Programming
    Replies: 11
    Last Post: 08-05-2002, 08:57 PM
  5. doubly linked lists
    By qwertiop in forum C++ Programming
    Replies: 3
    Last Post: 10-03-2001, 06:25 PM

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