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 targetProgram5.exe' failed
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:18: undefined reference to Dynque<char>::enqueue(char)' /cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:25: undefined reference toDynque<char>::dequeue(char&)'
/cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:28: undefined reference to Dynque<char>::isEmpty()' /cygdrive/c/Users/Shelby Jr/workspace/Program5/Debug/../file_filter.cpp:31: undefined reference toDynque<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;
}

When defining template functions or member functions of template classes, you can't put the definitions in a separate file from the declaration. Both the declaration and the definition need to be visible to the code that uses your functions. So you need to put the contents of Dynqueue.cpp into Dynqueue.h instead.

And yes, that's the complete opposite of what you're usually supposed to do, but that's how it is.

Awesome! Thanks for your help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.