I thought I was finished with my code until I tried to compile it and came out with an error that I really don't know where it's coming from. Can anyone look over and see if they can find the source of the error?
Please and thank you!
These are the errors I'm getting:
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:10: undefined reference to
Dynque<char>::Dynque()' makefile:44: recipe for target
Program5.exe' failed
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:18: undefined reference toDynque<char>::enqueue(char)' /cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:25: undefined reference to
Dynque<char>::dequeue(char&)'
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:28: undefined reference toDynque<char>::isEmpty()' /cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:31: undefined reference to
Dynque<char>::~Dynque()'
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:31: undefined reference to `Dynque<char>::~Dynque()'
#include<iostream>
#include<fstream>
#include<cctype>
#include"Dynqueue.h"
using namespace std;
int main()
{
Dynque<char> que;
char value;
bool empty = false;
ifstream inFile;
inFile.open( "input.txt" );
while( !inFile.eof() )
{
inFile >> value;
que.enqueue( value );
}
inFile.close();
ofstream outFile;
outFile.open( "input.txt" );
while( !empty )
{
que.dequeue( value );
value = toupper( value );
outFile << value;
empty = que.isEmpty();
}
outFile.close();
cout << "File filtered." << endl;
}
Dynqueue.h
#ifndef DYNQUEUE_H_
#define DYNQUEUE_H_
template <class T>
class Dynque
{
private:
struct QueueNode
{
T value;
QueueNode *next;
};
QueueNode *front;
QueueNode *rear;
int numItems;
public:
Dynque();
~Dynque();
void enqueue(T);
void dequeue(T &);
bool isEmpty();
};
#endif /* DYNQUEUE_H_ */
Dynqueue.cpp
#include"Dynqueue.h"
#include<cstdlib>
using namespace std;
template <class T>
Dynque<T>::Dynque()
{
front = NULL;
rear = NULL;
}
template <class T>
Dynque<T>::~Dynque()
{
QueueNode *currNode = front, *nextNode;
while( !currNode->next )
{
nextNode = currNode->next;
delete currNode;
currNode = nextNode;
}
front = NULL;
rear = NULL;
currNode = NULL;
nextNode = NULL;
}
template <class T>
void Dynque<T>::enqueue( T value )
{
QueueNode *newNode = NULL;
newNode = new QueueNode;
newNode->value = value;
newNode->next = NULL;
if( !front )
{
front = newNode;
rear = newNode;
}
else
{
newNode->next = front;
rear = rear->next;
front = newNode;
}
numItems++;
}
template <class T>
void Dynque<T>::dequeue( T &value )
{
QueueNode *prevNode = front;
while( prevNode->next != rear )
{
prevNode = prevNode->next;
}
value = rear->value;
delete rear;
rear = prevNode;
numItems--;
}
template <class T>
bool Dynque<T>::isEmpty()
{
bool isEmpty = false;
if( !front )
isEmpty = true;
else
isEmpty = false;
return isEmpty;
}