Trying to implement a queue using a doubly-linked list from <list>
, and I'm getting the following error for my print()
function: error C2760: syntax error: unexpected token 'identifier', expected ';'
The code for the Queue class is:
#ifndef DLL_QUEUE
#define DLL_QUEUE
#include <list>
#include <iostream>
using namespace std;
template<class T>
class Queue {
public:
Queue() {
}
void clear() {
lst.clear();
}
bool isEmpty() const {
return lst.empty();
}
T& front() {
return lst.front();
}
T dequeue() {
T el = lst.front();
lst.pop_front();
return el;
}
void enqueue(const T& el) {
lst.push_back(el);
}
void print() {
for (list<T>::const_iterator i = this->front(); i != this->back(); ++i)
cout << *i;
cout << "\n";
}
private:
list<T> lst;
};
#endif
The main method that is calling the class is:
#include <iostream>
#include "genQueue.h"
using namespace std;
int main() {
//"genQueue.h"
Queue<int> *queue1 = new Queue<int>();
for (int k = 0; k < 100; k++)
queue1->enqueue(k);
queue1->print();
system("PAUSE");
return 0;
}