Thread: please help with compile error

  1. #1
    Unregistered
    Guest

    please help with compile error

    using g++ compiler and keep getting compile error:
    linkedlist::processinputs(int, linkedlist)/var/tmp/ccd3DhwG.o
    ld:fatal:Symbol referencing errors. No output written
    collect2: ld returned 1 exit status

    here is the code:
    #include <iostream.h>
    #include <stdlib.h>
    #include <string.h>
    #include "linkedlist.h"

    linkedlist::linkedlist(char *s) // class constructor
    {
    strcpy(classname,s);
    }

    int processinputs(int in, linkedlist lst) // processinputs selects function for user
    {
    switch (in)
    {
    case 1:
    lst.addElement();
    break;
    case 2:
    lst.deleteElement();
    break;
    case 3:
    lst.queryElement();
    break;
    default:
    return -1;
    }
    return 0;
    }

    void linkedlist::addElement() // fills new student structure and adds to list
    {
    int resp;
    student head, *last;
    student *stuptr;
    head.next=NULL;
    head.prev=NULL;
    last=&head;
    stuptr=new student;

    cout<<" Enter name: ";
    cin>>stuptr->name;
    cout<<" Enter ID#: ";
    cin>>stuptr->id;
    cout<<" Enter the Major (1:Compsci 2:MIS 3:Elect 4:other): ";
    cin>>resp;
    switch (resp)
    {
    case 1:
    stuptr->major=comp_sci;
    break;
    case 2:
    stuptr->major=MIS;
    break;
    case 3:
    stuptr->major=Elect;
    break;
    case 4:
    stuptr->major=Others;
    break;
    }

    if( firstelement == NULL)
    {
    firstelement=stuptr;
    lastelement=stuptr;
    stuptr->next=NULL;
    stuptr->prev=NULL;
    }
    else
    {
    lastelement->next=stuptr;
    stuptr->prev=lastelement;
    stuptr->next=NULL;
    lastelement=stuptr;
    }

    }

    void linkedlist::queryElement() //searches list for element ID
    {
    int theid;

    cout<<" Enter ID to check: ";
    cin>>theid;

    currentelement=firstelement;
    do
    {
    if(currentelement->id == theid)
    {
    cout<<" Student found ";
    cout<<currentelement->name;
    }
    }
    while(currentelement != NULL);
    }

    void linkedlist::deleteElement() // deletes element from list
    {
    if(currentelement->prev==NULL)
    {
    firstelement=firstelement->next;
    }
    else
    {
    currentelement->prev->next=currentelement->next;
    }
    if(currentelement->next==NULL)
    {
    lastelement=lastelement->prev;
    }
    else
    {
    currentelement->next->prev=currentelement->prev;
    }
    delete currentelement;
    }

    void linkedlist::manipulate(linkedlist list) // manipulate called by manip_courses.cpp.
    // menu for user to select a function
    // linkedlist calls processinputs.
    {
    int input, retval;
    while(1)
    {
    system("clear");
    if(retval==-1)
    {
    cout<<"Input last entered was invalid"<<endl;
    }
    cout<<" WELCOME TO THE LINKED LIST PROGRAM"<<endl<<endl;
    cout<<" Enter 1 to create a student record"<<endl;
    cout<<" Enter 2 to delete a student record"<<endl;
    cout<<" Enter 3 to query the records"<<endl;
    cout<<" Enter 4 to quit"<<endl;
    cout<<": ";
    cin>>input;
    if ( input==4 )
    {
    system("clear");
    break;
    }
    retval=processinputs(input,list);
    }
    }

    linkedlist::~linkedlist() // class destructor
    {
    if (firstelement==NULL||lastelement==NULL)
    {
    return; // list is empty there is nothing to delete.
    }
    else
    {
    while(1)
    {
    if (lastelement->prev==NULL)
    {
    delete lastelement;
    break;
    }
    lastelement=lastelement->prev;
    delete lastelement->next;
    }
    }

    thanks for your help.

  2. #2
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    hm... 1 use code tags... 2 give us linkedlist.h

    >processinputs

    my guess is that processinputs was part of the linkedlist class, and you didn't preceed it's function with 'linkedlist::'... which gives you an unresolved external i believe...
    hasafraggin shizigishin oppashigger...

  3. #3
    Unregistered
    Guest
    here is linkedlist.h.

    enum possible_majors { // possible major types
    comp_sci,
    MIS,
    Elect,
    Others
    };

    struct student // student structure definition
    {
    char name[25];
    int id;
    possible_majors major;
    student *prev;
    student *next;
    };

    class linkedlist { // linkedlist class definition
    student *firstelement;
    student *lastelement;
    student *currentelement;
    char classname[40];
    int processinputs(int, linkedlist list); //used by manipulate
    public:
    void addElement();
    void queryElement();
    void deleteElement();
    void manipulate(linkedlist list);
    linkedlist(char *);
    ~linkedlist();
    };

    once again thanks for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginner Needs help in Dev-C++
    By Korrupt Lawz in forum C++ Programming
    Replies: 20
    Last Post: 09-28-2010, 01:17 AM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. DX - CreateDevice - D3DERR_INVALIDCALL
    By Tonto in forum Game Programming
    Replies: 3
    Last Post: 12-01-2006, 07:17 PM
  4. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  5. Problem with Visual C++ Object-Oriented Programming Book.
    By GameGenie in forum C++ Programming
    Replies: 9
    Last Post: 08-29-2005, 11:21 PM