Okay, I'm trying to implement a templated class of an array-based queue called Queue. Here's how I did it. First, is this the right way to implement a templated class? The problem is, when I try to compile, I get the error messages
undefined reference to 'Queue::Queue()'
undefined reference to 'Queue::~Queue()'
Any ideas what's wrong? Am I declaring it wrong or implementing it wrong?
queue.h
#ifndef __QUEUE_H__
#define __QUEUE_H__
template <class T>
class Queue
{
int first;
T* array;
public:
Queue();
~Queue;
void enqueue(T next);
T dequeue();
bool is_empty();
bool is_full();
};
#endif
queue.cpp
#include "queue.h"
template <class T> Queue<T>::Queue(){
...
}
template <class T> Queue<T>::~Queue(){
...
}
template <class T> void Queue<T>::enqueue(T next){
...
}
template <class T> T Queue<T>::dequeue(){
...
}
template <class T> bool Queue<T>::is_empty(){
...
}
template <class T> bool Queue<T>::is_full(){
...
}
main.cpp
#include "queue.h"
#include <iostream>
using namespace std;
int main(){
Queue<int> test;
return 0;
}