I'm creating a doubly linked list implementation of my own for fun and I've finished writing the list itself but now I'm trying to add an iterator to it, but I'm confused about the syntax rules for this stuff. Here is the error I'm getting:
error C2990: 'd_list' : non-class template has already been declared as a class template
Here's the header file it's all located in:
/****************************/
/* d_list class */
/* with exceptions classes */
/****************************/
class d_list_error{};
class d_list_empty{};
template <class T>
class d_list_iter;
template <class T>
class d_list{
public:
d_list();
d_list(const d_list &_dl);
d_list &operator=(const d_list &_dl);
~d_list();
void push_back(T item);
void push_front(T item);
void pop_back();
void pop_front();
bool isEmpty() const;
unsigned int size() const;
void clear();
private:
struct node{
node *prev;
node *next;
T data;
};
node *head;
node *tail;
unsigned int currSize;
d_list_iter<T> *dli;
/* Utility Functions */
void initFirstEle(T item, node* first);
void copyAll(const d_list<T> &_dl);
};
/*************************/
/* d_list iterator class */
/*************************/
class d_iter_already_exists {};
template <class T>
class d_list_iter{
public:
d_list_iter(const d_list &_dl);
~d_list_iter();
T getNext() const;
private:
friend class d_list;
d_list<T> *dl;
node *next;
node *prev;
bool valid;
};
Underneath that is all the member functions defined for d_list. I haven't started writing them for the iterator yet. d_list is working perfectly based on all my testing. I imagine I'm just running into syntax errors, as this is sort of uncharted territory for me.
iteratorfromconst_iterator.