I am implementing a generic doubly linked list and am getting an error due to the > and < operators. Can anyone help me out?
Note: I am not allowed to use any STL functions
typename SortedList<T>::iterator SortedList<T>::insert(const T& data) {
iterator it = begin();
if (head_->next_ == tail_) {
Node* newNode = new Node(data, tail_, head_);
head_->next_ = newNode;
tail_->prev_ = newNode;
it.curr_ = newNode;
++size_;
return it;
}
else {
while (it != end()) {
if ((*it < data) && (*it > data || it.curr_->next_ == tail_)) { // this line is giving me error
Node* newNode = new Node(data, it.curr_->next_, it.curr_);
it.curr_->next_->prev_ = newNode;
it.curr_->next_ = newNode;
it.curr_ = newNode;
++size_;
return it;
}
it++;
}
}
}
Aucun commentaire:
Enregistrer un commentaire