problem with compiling linkedqueue

The error is invisible to me. Im not sure why it wont compile? and the error code makes no sense.

error code

1>------ Build started: Project: project_4, Configuration: Debug Win32 ------
1>Build started 4/22/2012 4:28:46 PM.
1>InitializeBuildStatus:
1> Touching "Debug\project_4.unsuccessfulbuild".
1>ClCompile:
1> main.cpp
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall linkedQueueType<int>::linkedQueueType<int>(void)" (??0?$linkedQueueType@H@@QAE@XZ) referenced in function _main
1>C:\Users\SOYO\Documents\Visual Studio 2010\Projects\project_4\Debug\project_4.exe : fatal error LNK1120: 1 unresolved externals
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:01.46
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

main 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
#include <iostream>

#include "linkedQueue.h"

using namespace std;

int size = 1000;

int main()
{
	linkedQueueType<int> queue1, queue2;
	int x, y;

	queue1.initializeQueue();
	x = 4;
	y = 5;
	queue1.addQueue(x);
	queue1.addQueue(y);
	x = queue1.front();
	queue1.deleteQueue();
	queue1.addQueue(x + 5);
	queue1.addQueue(16);
	queue1.addQueue(x);
	queue1.addQueue(y - 3);
	queue1.addQueue(23);

	cout << "queue1 size is equal to " << queue1.queueCount() << endl;

	cout << "queue2 size is equal to " << queue2.queueCount() << endl;

	queue2 = queue1;

	cout << "new queue1 size is equal to " << queue1.queueCount() << endl;

	cout << "new queue2 size is equal to " << queue2.queueCount() << endl;

	while (!queue1.isEmptyQueue())
	{
		cout << queue1.front() << " ";
		queue1.deleteQueue();
	}

	cout << endl;

	cout << "queue2: ";

	while (!queue2.isEmptyQueue())
	{
		cout << queue2.front() << " ";
		queue2.deleteQueue();
	}

	cout << endl;

	return 0;
}


header file
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

#ifndef _NODE_
#define _NODE_

template <class Type>
struct Node                         // struct for storing some item
{                                   // in a linked list
    Type item;
    Node<Type> * next;
};

#endif

#ifndef H_linkedQueue
#define H_linkedQueue
  
#include <iostream>
#include <cassert>
#include <cstddef>
#include <new>

using namespace std;

template <class Type>
class linkedQueueType
{
public:
    const linkedQueueType<Type>& operator=(const linkedQueueType<Type>&); 
            // overload the assignment operator
    void initializeQueue();
    int isEmptyQueue() const {return ((queueFront) ? 0 : 1);};
	int queueCount();

    Type front() const;

    Type back() const;

    linkedQueueType<Type>& addQueue(const Type & newElement);
    void deleteQueue();

    linkedQueueType();
    linkedQueueType(const linkedQueueType<Type>& otherQueue); // copy constructor
    ~linkedQueueType(); //destructor

private:
	Node<Type> *lastElem;
    Node<Type> *queueFront;
    Node<Type> *queueRear;
	int count;
	Node<Type> * CopyList(const Node<Type> * ptr) const;
};

template <class Type>
linkedQueueType<Type>::~linkedQueueType()
{// Queue destructor.  Delete all nodes.
	Node<Type> *link;
	while (queueFront) {
		link = queueFront->next;
		delete queueFront;
		queueFront = link;
	}
}

template<class Type>
int linkedQueueType<Type>::queueCount()
{
	return count;
}

template<class Type>
void linkedQueueType<Type>::initializeQueue()
{
	count = 0;
    queueFront->next = queueRear;
	queueRear->next = queueFront;
}

template<class Type>
linkedQueueType<Type>& linkedQueueType<Type>::addQueue(const Type & newElement)
{
	Node<Type> *ptr;

	ptr = new Node<Type>;
	ptr->item = newElement;
	ptr->next = NULL;
	if (queueFront)
	{
		queueRear->next = ptr;
	}
	else
	{
		queueFront = ptr;
		queueRear = ptr;
	}

	count++;
	return *this;
}

template<class Type>
void linkedQueueType<Type>::deleteQueue()
{
	if(!isEmptyQueue()) 
	{
		Node<Type> *currNode = queueFront->next;
		for(int i = 0; i < count; i++)
		{
			currNode->item = 0;
			currNode = currNode->next;
		}
		count = 0;
	}
}

template<class Type>
Type linkedQueueType<Type>::front() const
{
    if (isEmptyQueue())   
	{ 
		cout<<"out of bounds";  
		return -1;
	}
	return queueFront->item;
}

template<class Type>
Type linkedQueueType<Type>::back() const
{
    if (isEmptyQueue()) 
	{ 
		cout<<"out of bounds";
		return -1; 
	}
	return queueRear->item;
}

template<class Type>
const linkedQueueType<Type>& linkedQueueType<Type>::operator=(const linkedQueueType<Type>& otherQueue)
{
    if (this != &otherQueue) //avoid self-copy
    {
		if (otherQueue.queueFront == NULL) 
		{
			queueFront = NULL;
			queueRear = NULL;
		}

		else 
		{
			queueFront = CopyList(otherQueue.queueFront);
			queueRear = queueFront;
			while (queueRear->next != NULL) 
			{
				queueRear = queueRear->next;
			}
		}
	}

    return *this;
}

template <class Type>
Node<Type> * linkedQueueType<Type>::CopyList(const Node<Type> * ptr) const
{
    if (ptr == NULL)
	{
        return NULL;
    }
    else {
        Node<Type> * temp = new Node<Type>;
        temp->item = ptr->item;
        temp->next = CopyList(ptr->next);
        return temp;
    }
}

template<class Type>
linkedQueueType<Type>::linkedQueueType(const linkedQueueType<Type>& otherQueue)
{
	if(otherQueue.queueFront == NULL)
	{
		queueFront = NULL;
		queueRear = NULL;
	}
	else
	{
		queueFront = CopyList(otherQueue.queueFront);
		queueRear = queueFront;
	}
	while (queueRear->next != NULL) 
	{
	    queueRear = queueRear->next;
	}
}

#endif 



Implement your class's constructor.
Okay, that definitely helped get the program running but thats as far as it goes, i get some crazy error after that and the program wont finish. but i dont really understand the error.

the error sits inside the initialize queue function, because thats where the error points to, i would copy but im not even sure how to.

the error says that

next= ????
item= ????

whatever that means

this is the only change i made

linkedQueueType() {queueFront = queueRear = NULL;};


heres the whole code for trying to see the error yourself

header file
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197

#ifndef _NODE_
#define _NODE_

template <class Type>
struct Node                         // struct for storing some item
{                                   // in a linked list
    Type item;
    Node<Type> *next;
};

#endif

#ifndef H_linkedQueue
#define H_linkedQueue
  
#include <iostream>
#include <cassert>
#include <cstddef>
#include <new>

using namespace std;

template <class Type>
class linkedQueueType
{
public:
    const linkedQueueType<Type>& operator=(const linkedQueueType<Type>&); 
            // overload the assignment operator
    void initializeQueue();
    int isEmptyQueue() const {return ((queueFront) ? 0 : 1);};
	int queueCount();

    Type front() const;

    Type back() const;

    linkedQueueType<Type>& addQueue(const Type & newElement);
    void deleteQueue();

    linkedQueueType() {queueFront = queueRear = NULL;};
    linkedQueueType(const linkedQueueType<Type>& otherQueue); // copy constructor
    ~linkedQueueType(); //destructor

private:
	Node<Type> *lastElem;
    Node<Type> *queueFront;
    Node<Type> *queueRear;
	int count;
	Node<Type> * CopyList(const Node<Type> * ptr) const;
};

template <class Type>
linkedQueueType<Type>::~linkedQueueType()
{// Queue destructor.  Delete all nodes.
	Node<Type> *link;
	while (queueFront) {
		link = queueFront->next;
		delete queueFront;
		queueFront = link;
	}
}

template<class Type>
int linkedQueueType<Type>::queueCount()
{
	return count;
}


template<class Type>
void linkedQueueType<Type>::initializeQueue()
{
	count = 0;
    queueFront->next = queueRear;
	queueRear->next = queueFront;
}

template<class Type>
linkedQueueType<Type>& linkedQueueType<Type>::addQueue(const Type & newElement)
{
	Node<Type> *ptr;

	ptr = new Node<Type>;
	ptr->item = newElement;
	ptr->next = NULL;
	if (queueFront)
	{
		queueRear->next = ptr;
	}
	else
	{
		queueFront = ptr;
		queueRear = ptr;
	}

	count++;
	return *this;
}

template<class Type>
void linkedQueueType<Type>::deleteQueue()
{
	if(!isEmptyQueue()) 
	{
		Node<Type> *currNode = queueFront->next;
		for(int i = 0; i < count; i++)
		{
			currNode->item = 0;
			currNode = currNode->next;
		}
		count = 0;
	}
}

template<class Type>
Type linkedQueueType<Type>::front() const
{
    if (isEmptyQueue())   
	{ 
		cout<<"out of bounds";  
		return -1;
	}
	return queueFront->item;
}

template<class Type>
Type linkedQueueType<Type>::back() const
{
    if (isEmptyQueue()) 
	{ 
		cout<<"out of bounds";
		return -1; 
	}
	return queueRear->item;
}

template<class Type>
const linkedQueueType<Type>& linkedQueueType<Type>::operator=(const linkedQueueType<Type>& otherQueue)
{
    if (this != &otherQueue) //avoid self-copy
    {
		if (otherQueue.queueFront == NULL) 
		{
			queueFront = NULL;
			queueRear = NULL;
		}

		else 
		{
			queueFront = CopyList(otherQueue.queueFront);
			queueRear = queueFront;
			while (queueRear->next != NULL) 
			{
				queueRear = queueRear->next;
			}
		}
	}

    return *this;
}

template <class Type>
Node<Type> * linkedQueueType<Type>::CopyList(const Node<Type> * ptr) const
{
    if (ptr == NULL)
	{
        return NULL;
    }
    else {
        Node<Type> * temp = new Node<Type>;
        temp->item = ptr->item;
        temp->next = CopyList(ptr->next);
        return temp;
    }
}

template<class Type>
linkedQueueType<Type>::linkedQueueType(const linkedQueueType<Type>& otherQueue)
{
	if(otherQueue.queueFront == NULL)
	{
		queueFront = NULL;
		queueRear = NULL;
	}
	else
	{
		queueFront = CopyList(otherQueue.queueFront);
		queueRear = queueFront;
	}
	while (queueRear->next != NULL) 
	{
	    queueRear = queueRear->next;
	}
}

#endif 


main file
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
#include <iostream>

#include "linkedQueue.h"

using namespace std;

int size = 1000;

int main()
{
	linkedQueueType<int> queue1, queue2;
	int x, y;

	queue1.initializeQueue();
	x = 4;
	y = 5;
	queue1.addQueue(x);
	queue1.addQueue(y);
	x = queue1.front();
	queue1.deleteQueue();
	queue1.addQueue(x + 5);
	queue1.addQueue(16);
	queue1.addQueue(x);
	queue1.addQueue(y - 3);
	queue1.addQueue(23);

	cout << "queue1 size is equal to " << queue1.queueCount() << endl;

	cout << "queue2 size is equal to " << queue2.queueCount() << endl;

	queue2 = queue1;

	cout << "new queue1 size is equal to " << queue1.queueCount() << endl;

	cout << "new queue2 size is equal to " << queue2.queueCount() << endl;

	while (!queue1.isEmptyQueue())
	{
		cout << queue1.front() << " ";
		queue1.deleteQueue();
	}

	cout << endl;

	cout << "queue2: ";

	while (!queue2.isEmptyQueue())
	{
		cout << queue2.front() << " ";
		queue2.deleteQueue();
	}

	cout << endl;

	return 0;
}



if anyone can figure anything out about this it would be so very greatly appreciated, in the mean time ill be trying out different methods to fix this, none of which im sure will work.
Last edited on
Topic archived. No new replies allowed.