Dynamic Queue Template

I've built an almost complete version of a dynamic queue template, but I keep getting unresolved externals. I've compiled the program without writing anything in main and I get no errors, but when I try to call any of the functions, I get errors.

I've gone through my header and implementation files, and fixed a few things, but nothing has fixed the errors I'm getting. I'll post the code here:

QueueTemplate.h
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
38
39
40
41
42
#ifndef QUEUETEMPLATE_H
#define QUEUETEMPLATE_H
#include <iostream>

using namespace std;
#pragma once

template <class T>
class QueueTemplate
{
private:
//Struct for nodes
struct qNode
{
	T data;        //Node's value
	qNode *next;   //Pointer
};

qNode *front;   //Pointer, holds the front of the queue
qNode *back;    //Pointer, holds the back of the queue

int queueNum;   //Tracks number of items in queue

public:

	//Constructor
	QueueTemplate();

	//Destructor
	~QueueTemplate();

	//Operations

	void enqueue(T);
	void dequeue(T &);
	bool isEmpty() const;

	void destroyQueue();
    

};
#endif  


QueueTemplate.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include <iostream>
#include <string>
#include "QueueTemplate.h"

using namespace std;


template <class T>
QueueTemplate<T>::QueueTemplate()
{
	front = NULL;
	back = NULL;
	queueNum = 0;
}

template <class T>
QueueTemplate<T>::~QueueTemplate()
{
	destroyQueue();
}

template <class T>
void QueueTemplate<T>::enqueue(T val)
{
	qNode *newNode;

	//Create new node, have it hold val
	newNode = new qNode;
	newNode->data = val;
	newNode->next = NULL;

	//Change front and back pointers,
	//depending if the queue is empty or already contains data

	if (isEmpty())
	{
		front = newNode;
		back = newNode;
	}
	else
	{
		back->next = newNode;
		back = newNode;
	}

	//update number of items in queue
	queueNum++;
}

template <class T>
void QueueTemplate<T>::dequeue(T &val)
{
	qNode *temp;

	if(isEmpty())
	{
		cout << "No data currently queued" << endl;
	}
	else
	{
		//Store data from front node in val
		val = front->data;
		//Remove front node, delete
		temp = front;
		front = front->next;
		delete temp;

		//Update queueNum
		queueNum--;
	}
}

template <class T>
bool QueueTemplate<T>::isEmpty() const
{
	bool empty;

	if(queueNum > 0) 
		empty = false;
	else
		empty = true;
	

	return empty;
}

template <class T>
void QueueTemplate<T>::destroyQueue()
{
	T temp;

	while(!isEmpty())
	{
		dequeue(data);
	}
}


main (not complete yet)
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
38
39
40
41
//Driver for QueueTemplate class
#include <iostream>
#include <string>
#include "QueueTemplate.h"

using namespace std;

int main()
{
	string word;
	int number;

	//Creating queues
	QueueTemplate<string> strque;
	QueueTemplate<int> intque;

	cout << "We have a queue to hold names." << endl;
	cout << "Our queue of names is " << (strque.isEmpty() ? "Empty" : "Not Empty");

	cout << "We will put three names into our queue." << endl;

	//Enqueueing names...
	for (int n = 0; n < 3; n++)
	{
		cout << "Enter name: " << endl;
		getline(cin, word);
		strque.enqueue(word);
	}

	cout << "Our queue of names is " << (strque.isEmpty() ? "still empty" : "no longer empty");
	cout << "The program will read back the names in the order they were entered.\n";

	for (int n = 0; n < 3; n++)
	{
		strque.dequeue(word);
		cout << word << endl;
	}


	return 0;
}


I appreciate any help. I'm sure this is yet another small problem I'm repeatedly overlooking.
I can't believe I forgot to combine definition and implementation. Looking back at my book, it mentioned this with templates, but I'd completely forgotten about it.

Thanks a lot, ne555.
Topic archived. No new replies allowed.