Hi,
I'm trying to write a simple Queue class, but I'm having trouble using it. It tells me I have undefined references to the functions I call in main.
// main.cpp
#include <iostream>
#include "queue.h"
void main()
{
Queue<int> myq;
myq.push(10);
std::cout << myq.isempty() << endl;
myq.makeempty();
std::cout << myq.isempty() << endl;
}
// queue.h
#include <vector>
using namespace std;
template <typename U>
class Queue
{
public:
void push(U const &);
void pop();
bool isempty();
void makeempty();
private:
vector<U>info;
};
// queue.cpp
template <typename T> void Queue<T>::push(T const & tmp)
{
info.push_back(tmp);
}
template <typename T> void MyQueue<T>::pop()
{
info.erase(info.begin(), info.begin() + 1);
}
template <typename T> bool isempty()
{
return (info.empty());
}
template <typename T> void makeempty()
{
info.erase(info.begin(), info.end());
}
Any ideas?