I know how to implement a template class.
However, I don't understand how the following list<int>::iterator
is implemented internally. Should I make a namespace?
(Basically I want to use the same STL syntax with customized implementation.)
list<int> l;
list<int>::iterator it = l.begin();
In short, what is the simplest way to get the code working without any STL libraries?
Here is a snippet of the custom list implementation: (I omitted most of the methods for readability.)
template <typename T>
struct list {
struct listNode {
listNode() : item(0), next(0) {}
listNode(T x) : item(x), next(0) {}
T item;
listNode* next;
};
list() : head(0),tail(0) {}
listNode* head;
listNode* tail;
};