Undefined referencec to ...

Posted by Patrick LaChance on Stack Overflow See other posts from Stack Overflow or by Patrick LaChance
Published on 2010-04-02T21:52:34Z Indexed on 2010/04/02 21:53 UTC
Read the original article Hit count: 357

Filed under:
|
|

I keep getting this error message every time I try to compile, and I cannot find out what the problem is. any help would be greatly appreciated:

C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::List()' C:\DOCUME~1\Patrick\LOCALS~1\Temp/ccL92mj9.o:main.cpp:(.txt+0x184): undefined reference to 'List::add(int)' collect2: ld returned 1 exit status

code:

//List.h

ifndef LIST_H

define LIST_H

include

//brief Definition of linked list class

class List { public:

/**
\brief Exception for operating on empty list
*/  


class Empty : public std::exception

{ public: virtual const char* what() const throw(); };

/**
\brief Exception for invalid operations other than operating on an empty list
*/

class InvalidOperation : public std::exception

{ public: virtual const char* what() const throw(); };

/**
\brief Node within List
*/


class Node

{ public: /** data element stored in this node */ int element;

/** next node in list / Node next;

/** previous node in list / Node previous;

Node (int element); ~Node();

void print() const; void printDebug() const; };

List();
~List();

void add(int element);
void remove(int element);
int first()const;
int last()const;
int removeFirst();
int removeLast();
bool isEmpty()const;
int size()const;
void printForward() const;    
void printReverse() const;
void printDebug() const;

/**
enables extra output for debugging purposes
*/
static bool traceOn;

private:
/** head of list */
Node* head;
/** tail of list */
Node* tail;
/** count of number of nodes */
int count;

};

endif

//List.cpp I only included the parts of List.cpp that might be the issue

include "List.h"

include

include

using namespace std;

List::List() { //List::size = NULL; head = NULL; tail = NULL; }

List::~List() { Node* current; while(head != NULL) { current = head-> next; delete current->previous; if (current->next!=NULL) { head = current; } else { delete current; } } }

void List::add(int element) { Node* newNode; Node* current; newNode->element = element; if(newNode->element > head->element) { current = head->next; } else { head->previous = newNode; newNode->next = head; newNode->previous = NULL; return; }

while(newNode->element > current->element) { current = current->next; }

if(newNode->element <= current->element) { newNode->previous = current->previous; newNode->next = current; }

}

//main.cpp

include "List.h"

include

include

using namespace std; //void add(int element);

int main (char** argv, int argc) {
List* MyList = new List(); bool quit = false; string value; int element;

while(quit==false) { cin>>value;

if(value == "add") { cin>>element; MyList->add(element); } if(value=="quit") { quit = true; } } return 0; }

I'm doing everything I think I'm suppose to be doing. main.cpp isn't complete yet, just trying to get the add function to work first. Any help will be greatly appreciated.

© Stack Overflow or respective owner

Related posts about c++

Related posts about undefined

  • Error in running script [closed]

    as seen on Programmers - Search for 'Programmers'
    I'm trying to run heathusf_v1.1.0.tar.gz found here I installed tcsh to make build_heathusf work. But, when I run ./build_heathusf, I get the following (I'm running that on a Fedora Linux system from Terminal): $ ./build_heathusf Compiling programs to build a library of image processing functions… >>> More

  • Not able to compile dbus-ping-pong

    as seen on Ask Ubuntu - Search for 'Ask Ubuntu'
    I have downloaded files from http://cgit.collabora.com/git/user/alban/dbus-ping-pong.git/tree/ I am trying to compile it using the command gcc pkg-config --libs --cflags dbus-1 dbus-glib-1-2 glib-2.0 -o dbus-ping-pong dbus-ping-pong.c However, I get errors: /tmp/ccmJkxXb.o: In function g_once_init_enter: dbus-ping-pong… >>> More

  • Qt Linking Error.

    as seen on Stack Overflow - Search for 'Stack Overflow'
    Hi, I configure qt-x11 with following options ./configure -prefix /iTalk/qtx11 -prefix-install -bindir /iTalk/qtx11-install/bin -libdir /iTalk/qtx11-install/lib -docdir /iTalk/qtx11-install/doc -headerdir /iTalk/qtx11-install/include -datadir /iTalk/qtx11-install/data -examplesdir /iTalk/qtx11-install/examples… >>> More

  • QtOpenCl make errors. Please help.

    as seen on Stack Overflow - Search for 'Stack Overflow'
    So I downloaded the ATI Stream SDK. I don't have a gpu now so I use the '-device cpu' and got the programs/examples in the OpenCl directory working by adding the directory to LD_LIBRARY_PATH etc. Now the problem is when installing QtOpenCl. configure script gives me: skkard@skkard-desktop:~/Applications/qt-labs-opencl$… >>> More

  • Handling Erlang inets http client errors

    as seen on Stack Overflow - Search for 'Stack Overflow'
    I have an Erlang app which makes a large number of http calls to external sites using inets, using the code below case http:request(get, {Url, []}, [{autoredirect, false}], []) of {ok, {{_, Code, _}, _, Body}}-> case Code of 200 -> HandlerFn(Body); _ -> {error… >>> More