Mar 3, 2016 at 2:15pm UTC
Hi. I'm trying to build a Linked List that will hold objects of previously defined class; I'm working in VS2010, and it's giving me problems.
Please take a look>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
#pragma once
#include "Customers.h"
class LinkedList
{
public :
LinkedList(void );
~LinkedList(void );
struct ListNode
{
Customer value;
ListNode *next;
ListNode(Customer v, ListNode *n);
};
ListNode* head;
void add(Customer v);
void del(Customer v);
int findPlace(std::string n);
void printList();
Customer getHead();
};
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include "LinkedList.h"
LinkedList::LinkedList(void )
{
head = NULL;
}
LinkedList::~LinkedList(void )
{
ListNode* tmp = head;
while (tmp!= NULL)
{
tmp = head;
head = head->next;
delete [] tmp;
}
}
void LinkedList::add(Customer v)
{
if (head == NULL)
{
ListNode* tmp = NULL;
head = new ListNode(v, tmp); // I believe this line is making a problem
} else
{
//here, I also need memory allocation
ListNode* tmp = head;
while (tmp->next != NULL)
tmp = tmp->next;
tmp->next->next = NULL;
tmp->next->value = v;
}
}
What I get is LNK2019 error.
Does anybody have a idea of how to solve this?
Last edited on Mar 3, 2016 at 2:16pm UTC
Mar 3, 2016 at 2:21pm UTC
This means that you're tying to use a function (or other such) it can't find, because it doesn't exist or you haven't linked the right object file or library.
The error tells you what it can't find. Look at the whole error and see what it can't find.
Last edited on Mar 3, 2016 at 2:22pm UTC