Error message (undefined reference) Linking Issue.

I

israphelr

Hi all,

I am writing a linked list for an assignment where I am using classes
for nodes and a linked list class to handle the node objects.

However when I try and link the object files I get the following error
message:

llist.o(.text+0xb6):llist.cpp:undefined reference to 'node::node[in-
charge](int, int, std::basic_string<char, std::char_traits<char>,
std::allocator<char> >)' collect2 ld returned 1 exit status.

I just can't see what it is, so some help would be very much
appreciated.

Here's the code...

#include <iostream>
#include "llist.h"

using namespace std;

int main()
{
LinkedList l; //instantiate a linked list.


if (l.isListEmpty())
cout << "Empty!" << endl;
else
cout << "Non Empty" << endl;
return 0;
}

/*********************************/

/*
llist.h - define a list
*/

#include "node.h"

typedef node* PNode;

class LinkedList
{
public:
LinkedList();
int setHead();
int isListEmpty();
void addNode();

private:
PNode head;
};



/*********************************/

// llist.cpp

#include <string>
#include "llist.h"

using namespace std;

LinkedList::LinkedList()
{
setHead();
}

int LinkedList::setHead()
{
head = NULL;
}

int LinkedList::isListEmpty()
{
return (head == NULL);
}


void LinkedList::addNode()
{
PNode tmp;
string s;
s = "London";
tmp = new node(2,4,s); // << This line is what I am
trying to do before I get the linking problem
head = tmp;
}

/**********************************/

//node.h - define a node.

#include <string>
using namespace std;

class node
{
public:
node(int a, int b, string name);
void setX(int a);
void setY(int b);
void setName(string name);
void setNext();
int getX();
int getY();
string getName();
int getNext();


private:
int x;
int y;
string cityname;
node* next;
};

/***********************************/

//node.cpp

#include <string>
#include "node.h"

using namespace std;

node::node(int a, int b, string name)
{
setX(a);
setY(b);
setName(name);
setNext();
}

void node::setX(int a)
{
x = a;
}

void node::setY(int b)
{
y = b;
}

void node::setName(string name)
{
cityname = name;
}

void node::setNext()
{
next = NULL;
}

int node::getX()
{
return x;
}

int node::getY()
{
return y;
}

string node::getName()
{
return cityname;
}

int node::getNext()
{
return (next == NULL);
}

/******************************/

Many many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top