0

Hi, I'm having trouble with my program,here is one of the error code:

Error 1 error LNK2019: unresolved external symbol "public: __thiscall linkedListType<int>::linkedListType<int>(void)" (??0?$linkedListType@H@@QAE@XZ) referenced in function "public: __thiscall linkedQueueType<int>::linkedQueueType<int>(void)" (??0?$linkedQueueType@H@@QAE@XZ) main.obj Mesina_Wk5Assignment

The following are the codes to my program

// linkedList.h file

#ifndef H_LinkedList
#define H_LinkedList

#include <iostream>
#include <cassert>

using namespace std;

//Definition of the node

template<class Type>
struct nodeType
{
	Type info;
	nodeType<Type> *link;
};

template <class Type>
class linkedListType
{
	friend ostream& operator<<(ostream&, const linkedListType<Type>&);
	//Overlaod the stream insertion operator.

public:
	const linkedListType<Type>& operator=
		(const linkedListType<Type>&);
	//Overload the assignment operator.
	void initializeList();
	
	bool isEmptyList();

	int length();

	void destroyList();

	Type front();

	Type back();

	bool search(const Type& newItem);

	void insertFirst (const Type& newItem);

	void insertLast (const Type&  newItem);

	void deleteNode (const Type& deleteItem);

	linkedListType();

	linkedListType(const linkedListType<Type>& otherList);
	// copy constructor

	~linkedListType();

protected:
	int count;
	nodeType<Type> *first;
	nodeType<Type> *last;

private:
	void copyList (const linkedListType<Type>& otherList);
};
#endif


//linkedList.cpp file

#include <iostream>
#include <cassert>

#include "linkedList.h"

using namespace std;

template<class Type>
void linkedListType<Type>::initializeList()
{
	destroyList();	// if the list has any nodes, delete them.
}

template<class Type>
bool linkedListType<Type>::isEmptyList()
{
	return (first == NULL);
}

template<class Type>
int linkedListType<Type>::length()
{
	return count;
}

template <class Type>
void linkedListType<Type>::destroyList()
{
	noteType<Type> *temp;

	while (first != NULL)
	{
		temp = first;
		first = first ->link;
		delete temp;
	}

	last = NULL;
	count = 0;
}

template<class Type>
Type linkedListType<Type>::front()
{
	assert(last != NULL);
	return first -> info;
}

template<class Type>
Type linkedListType<Type>::back()
{
	assert (last != NULL);
	return last -> info;
}

template <class Type>
bool linkedListType<Type>::search(const Type& searchItem)
{
	nodeType<Type> *current;
	bool found;
	current = first;
	found = false;

	while (current !=NULL && !found)
		if (current ->info == searchItem)
			found = true;
		else 
			current = current->link;

	return found;
}

template<class Type>
void linkedListType<Type>::insertFirst(const Type &newItem)
{
	noteType<Type> *newNode;
	newNode = new nodeType<Type>;
	assert (newNode != NULL);
	newNode -> info = newItem;
	newNode -> link = first;
	first = newNode;
	count ++;

	if (last == NULL)
		last = newNode;
}

template<class Type>
void linkedListType<Type>::insertLast(const Type &newItem)
{
	nodeType<Type> *newNode;
	newNode = new nodeType<Type>;
	assert (newNode != NULL);
	newNode -> info = newItem;
	newNode -> link = NULL;

	if first (first == NULL)
	{
		first = newNode;
		last = newNode;
		count ++;
	}

	else 
	{
		last -> link = newNode;
		last = newNode;
		count ++;
	}
}// end insert last

template<class Type>
void linkedListType<Type>::deleteNode(const Type &deleteItem)
{
	nodeType<Type> *current;
	nodeType<Type> *trailCurrent;
	bool found;

	if (first == NULL)	//Case 1; list is empty.
		cerr<<"Cannot delete from an empty list.\n";
	else
	{
		if (first -> info == deleteItem) // Case 2
		{
			current = first;
			first = first -> link;
			count --;
			if (first == NULL)
				last = NULL;
			delete current;
		}
		else	// Search the list for the node with the given info
		{
			found = falst;
			trailCurrent = first;
			current = first -> link;

			while (current != NULL && !found)
			{
				if (current -> info != deleteItem)
				{
					trailCurrent = current;
					current = current -> link;
				}
				else
					found = true;
			}// end while

			if (found) // Case 3; if found, delete the node
			{
				trailCurrent -> link = current -> link;
				count --;

				if (last == current)
					last = trailCurrent;
				delete current;
			}
			else
				cout << "Item to be deleted is not in the list." << endl;
		}// end else
	}// end else
}// end deleteNode

template<class Type>
linkedListType<Type>::linkedListType() // default constructor
{
	first = NULL;
	last = NULL;
	count = 0;
}

template<class Type>
linkedListType<Type>::linkedListType // copy constructor
(const linkedListType<Type>& otherList)
{
	first = NULL;
	copyList (otherList);
}

template<class Type>
linkedListType<Type>::~linkedListType() // destructor
{
	destroyList();
}

template<class Type>
void linkedListType<Type>::copyList(const linkedListType<Type> &otherList)
{
	nodeType<Type> *newNode;
	nodeType<Type> *current;

	if (first != NULL)
		destroyList();
	if (otherList.first == NULL)
	{
		first = NULL;
		last = NULL;
		count = 0;
	}
	else
	{
		current = otherList.first;
		cout = otherList.count;
			//copy the first Node
		first = new nodeType<Type>; // creates the node

		assert (first != NULL);
		first -> info = current -> info;
		first -> link = NULL;
		last = first;
		current = current -> link;
		
		// copy the remaining list
		while(current != NULL)
		{
			newNode = new nodeType<Type>;
			assert (newNode != NULL);

			newNode -> info = current -> info;
			newNode -> link = NULL;

			last -> link = newNode;
			last = newNode;

			current = current -> link;
		} // end while
	} // end else
} // end copyList

template<class Type>
const linkedListType<Type>& linkedListType<Type>::operator =
(const linkedListType<Type>& otherList)
{
	if (this != &otherList) // avoid self copy
		copyList (otherList);

	return *this;
}


// queueLinked.h file
// Queue derived from the class linkedListType

#ifndef H_QueueType
#define H_QueueType

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

using namespace std;

template<class Type>
class linkedQueueType: public linkedListType<Type>
{
public:
	bool isEmptyQueue();
	bool isFullQueue();
	void destroyQueue();
	void initializeQueue();
	void addQueue(const Type& newElement);
	Type front();
	Type back();
	void deleteQueue();
};

template<class Type>
void linkedQueueType<Type>::initializeQueue()
{
	linkedListType<Type>::initializeList();
}

template<class Type>
void linkedQueueType<Type>::deleteQueue()
{
	linkedListType<Type>::destroyList();
}

template<class Type>
bool linkedQueueType<Type>::isEmptyQueue()
{
	return linkedListType<Type>::isEmptyList();
}

template<class Type>
bool linkedQueueType<Type>::isFullQueue()
{
	return false;
}

template<class Type>
void linkedQueueType<Type>::addQueue(const Type &newElement)
{
	linkedListType<Type>::insertLast(newElement);
}

template<class Type>
Type linkedQueueType<Type>::front()
{
	return linkedListType<Type>::front();
}

template<class Type>
Type linkedQueueType<Type>::back()
{
	return linkedListType<Type>::back();
}

template<class Type>
void linkedQueueType<Type>::destroyQueue()
{
	nodeType<Type> *temp;

	if (!isEmptyQueue())
	{
		temp = first;
		first = first -> link;
		delete temp;
		count --;
		if (first == NULL)
			last = NULL;
	}
	else 
		cerr << "Cannot remove from an empty queue." << endl;
}
#endif


// main.cpp file

#include <iostream>
#include <string>
#include "linkedList.h"
#include "queueLinked.h"

using namespace std;

int main()
{
	linkedQueueType<int> queue;
	linkedQueueType<int> copyQueue;

	int num;

	cout << "Queue Operations" << endl;
	cout << "Enter numbers ending with -999" << endl;
	cin >> num;

	while (num != -999)
	{
		queue.addQueue (num);	//add an element to the queue
		cin >> num;
	}

	copyQueue = queue;	//copy the queue into copyQueue

	cout << "Queue contains: ";
	while (!copyQueue.isEmptyQueue())
	{
		cout << copyQueue.front() << " ";
		copyQueue.deleteQueue();	// remove an element from the que
	}

	cout << endl;
	return 0;
}

Please help, I really appreciate it. Thank you.

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by jonsca
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.