-
Node
wants a constructorNode(const Type& tp, Node * prev = nullptr, Node * next = nullptr) : element(tp) , prev(prev) , next(next) {}
-
What can be simplified
push
s andpop
s. There is common functionality between a special and common cases. Consider for examplepush_front
: after the push a new node would becomehead
, no matter what:push_front(const Type& tp) { node = new Node(tp, nullptr, head); if (head == 0) { tail = node; } else { head->prev = node; } head = node; }
Other three function can be similarly streamlined.
A copy constructor shares too much code with
push_back
. Consider consolidating the common base. Ditto for a destructor andclear
.You may want to assert your invariants: if you have, say,
head == nullptr
, you must also havetail == nullptr
andcount == 0
.