Click here to Skip to main content
15,914,221 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VS .NET Pin
shultas29-Dec-03 15:27
shultas29-Dec-03 15:27 
GeneralRe: VS .NET Pin
Michael Dunn29-Dec-03 15:36
sitebuilderMichael Dunn29-Dec-03 15:36 
GeneralRe: VS .NET Pin
shultas29-Dec-03 16:37
shultas29-Dec-03 16:37 
GeneralRe: VS .NET Pin
Tim Smith29-Dec-03 18:40
Tim Smith29-Dec-03 18:40 
GeneralRe: VS .NET Pin
Anonymous29-Dec-03 20:38
Anonymous29-Dec-03 20:38 
GeneralRe: VS .NET Pin
Tim Smith30-Dec-03 1:00
Tim Smith30-Dec-03 1:00 
GeneralRe: VS .NET Pin
Anonymous30-Dec-03 22:36
Anonymous30-Dec-03 22:36 
GeneralIterator Pin
Andre Pham29-Dec-03 8:31
Andre Pham29-Dec-03 8:31 
Hello

Below is my code about List Iterator. It is ok when
i compile it. But when i try to build it. the following
errors come up.

"DoubleOrderedLinkedList.obj : error LNK2019: unresolved external symbol "public: int __thiscall ListIterator::getNext(void)" (?getNext@?$ListIterator@H@@QAEHXZ) referenced in function _main"

Could any body here help me solve this problem?

Thanks,

Andre
------------------------------------------------
template
class DoubleOrderedLinkedList;

template
class ListIterator;

template
class Node
{
Object data;
Node * next;
Node * prev;

Node(const Object& newItem) :
data (newItem),
next (0),
prev (0)
{}

friend DoubleOrderedLinkedList<object>;
friend ListIterator<object>;
};

template
class DoubleOrderedLinkedList
{
Node<object>* head;
int numItems;

public:
DoubleOrderedLinkedList();
~DoubleOrderedLinkedList();

int size() const;
void Insert(const Object&);
void Remove(const Object&);
void Purge();
void displayList() const;
ListIterator<object> Iterator() const;

friend ListIterator<object>;
};

template
class ListIterator
{
int pos;
Node<object>* curr;

public:
ListIterator(Node<object>* const);
bool hasNext() const;
Object getNext();
bool hasPrevious() const;
Object getPrevious();
};

#include
#include "DoubleOrderedLinkedList.h"
#include "ListIterator.h"

using namespace std;

template
DoubleOrderedLinkedList<object>::DoubleOrderedLinkedList() :
head (0),
numItems (0)
{}

template
DoubleOrderedLinkedList<object>::~DoubleOrderedLinkedList()
{}

template
DoubleOrderedLinkedList<object>::size() const
{
return numItems;
}

template
ListIterator<object> DoubleOrderedLinkedList<object>::Iterator() const
{
ListIterator<object> it (head);
return it;
}

template
void DoubleOrderedLinkedList<object>::Insert(const Object& x)
{
Node<object>* previous = 0;
Node<object>* curr = head;

while ((curr != 0) && (curr->data < x))
{
previous = curr;
curr = curr->next;
}

Node<object> * const newNode = new Node<object> (x);
if (head == 0)
{
head = newNode;
}
else
{
if (curr == head)
{
newNode->next = curr;
curr->prev = newNode;
head = newNode;
}
else
{
if (curr != 0)
{
newNode->next = curr;
newNode->prev = curr->prev;
curr->prev->next = newNode;
curr->prev = newNode;
}
else
{
newNode->prev = previous;
previous->next = newNode;
}
}
}
numItems++;
}

template
void DoubleOrderedLinkedList<object>::displayList() const
{
Node<object>* ptr = head;
cout << "[ ";
while (ptr != 0)
{
cout << ptr->data << " ";
ptr = ptr->next;
}
cout << " ]" << endl;
}


int main()
{
DoubleOrderedLinkedList l;
l.Insert(10);
l.Insert(5);
l.Insert(15);
l.displayList();
ListIterator it = l.Iterator();
cout << "Testing Iterator" << endl;
while (it.hasNext())
{
cout << it.getNext() << endl;
}
}

#include "DoubleOrderedLinkedList.h"
#include "ListIterator.h"

template
ListIterator<object>::ListIterator(Node<object>* const p) :
pos (0),
curr (p)
{}

template
bool ListIterator<object>::hasNext() const
{
return (pos < numItems);
}

template
Object ListIterator<object>::getNext()
{
if (hasNext())
{
Object item = curr->data;
if (curr->next != 0) {
curr = curr->next;
}
pos++;
return item;
}
else
{
//throw(Exception("No Such Element");
}
}

template
bool ListIterator<object>::hasPrevious() const
{
return (pos > 0);
}

template
Object ListIterator<object>::getPrevious()
{
if (hasPrevious())
{
if ((curr.prev != 0) && (pos < numItems))
{
curr = curr->prev;
}
Object item = curr->data;
pos--;
return item;
}
else
{
//throw(Exception("No Such Element");
}
}
GeneralRe: Iterator Pin
Rafael Fernández López29-Dec-03 10:55
Rafael Fernández López29-Dec-03 10:55 
GeneralRe: Iterator Pin
Jörgen Sigvardsson29-Dec-03 11:10
Jörgen Sigvardsson29-Dec-03 11:10 
GeneralPassing DB handle between applications Pin
Member 56390729-Dec-03 8:29
Member 56390729-Dec-03 8:29 
GeneralRe: Passing DB handle between applications Pin
David Crow29-Dec-03 8:35
David Crow29-Dec-03 8:35 
GeneralRe: Passing DB handle between applications Pin
Brian Shifrin29-Dec-03 10:39
Brian Shifrin29-Dec-03 10:39 
GeneralRe: Passing DB handle between applications Pin
Jörgen Sigvardsson29-Dec-03 11:13
Jörgen Sigvardsson29-Dec-03 11:13 
Generaldatabase error Pin
ansontong29-Dec-03 7:41
ansontong29-Dec-03 7:41 
GeneralRe: database error Pin
David Crow29-Dec-03 8:27
David Crow29-Dec-03 8:27 
GeneralRe: database error Pin
ansontong29-Dec-03 9:18
ansontong29-Dec-03 9:18 
GeneralRe: database error Pin
David Crow30-Dec-03 2:46
David Crow30-Dec-03 2:46 
Generaldll build problem Pin
will138329-Dec-03 6:00
will138329-Dec-03 6:00 
GeneralRe: dll build problem Pin
Brian Shifrin29-Dec-03 7:19
Brian Shifrin29-Dec-03 7:19 
GeneralMAPI Help Please! Pin
LizardWiz29-Dec-03 5:45
LizardWiz29-Dec-03 5:45 
GeneralRe: MAPI Help Please! Pin
David Crow29-Dec-03 5:58
David Crow29-Dec-03 5:58 
GeneralRe: MAPI Help Please! Pin
LizardWiz29-Dec-03 11:12
LizardWiz29-Dec-03 11:12 
GeneralRe: MAPI Help Please! Pin
Shog929-Dec-03 9:39
sitebuilderShog929-Dec-03 9:39 
GeneralPassing one-dimensional arrays to functions Pin
pf729-Dec-03 4:32
pf729-Dec-03 4:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.