Please try to compile your code.
If the templates are bothering you then try
1 2 3 4
|
//template<class T>
class list{
typedef int value_type;
//typedef T value_type;
|
1)
1 2 3 4 5 6 7 8 9 10 11
|
void
list::push_back(const value_type& x){} //non template
template<class T>
void
list<T>::push_back(const value_type& x){} //template
list::iterator&
list::iterator::operator++(){} //non template (note that iterator is an inner class)
template<class T>
typename list<T>::iterator& //dependent name
list<T>::iterator::operator++(){} //template
|
You've got several member functions in the wrong place. By instance, `erase()' should be a function of list, no of iterator, and it is weird that `iterator' can give you begin() and end().
2) You don't have a dereference operator yet.
3) For reverse you could simply do
1 2
|
traverse(node, list)
swap(node.prev, node.next)
|
4) `erase()' should ask for an iterator. The client has no way to send it a Node*.
You could avoid especial cases, simplifying your functions, by making a `circular' list with a header `cell' (that has no data)
You shouldn't dereference in line 147,148. You need to handle the pointers.
To make your iterator work with `std::algorithm' check out `iterator_traits'
Also, you may want to drop
using namespace std;
it could give you conflict
By the way
1 2 3 4
|
Node(T data):
createNode(data) //copy constructor
{
//createNode = data; //assignment operator
|