@huxi, а у меня Ваш код вообще не компилируется.
avp@avp-ubu1:hashcode$ g++ huxilist.cpp
huxilist.cpp: In copy constructor ‘List::List(const List&)’:
huxilist.cpp:16:47: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::begin()’ discards qualifiers [-fpermissive]
huxilist.cpp:16:60: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::end()’ discards qualifiers [-fpermissive]
huxilist.cpp: In member function ‘List& List::operator=(const List&)’:
huxilist.cpp:37:27: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::begin()’ discards qualifiers [-fpermissive]
huxilist.cpp:37:40: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::end()’ discards qualifiers [-fpermissive]
huxilist.cpp: In function ‘int main()’:
huxilist.cpp:114:9: error: ‘List_m’ has not been declared
huxilist.cpp:114:23: error: ‘it1’ was not declared in this scope
huxilist.cpp:114:29: error: ‘listfile’ was not declared in this scope
avp@avp-ubu1:hashcode$
Вы уж проверьте, что выложили.
UPDATE
@huxi, тогда в комментарии я написал достаточно общую функцию удаления, работающую вообще вне какого-либо класса. Откровенно говоря, я не стал разбираться, в чем именно у Вас ошибка в реализации метода delete_node().
Вот такая реализация (применительно к Вашему классу List) вроде бы работает:
int delete_node (Node *x) {
if (!x || !head)
return -1;
if (x == head) {
head = x->next;
delete x;
return 0;
}
for (Node *t = head; t; t = t->next)
if (t->next == x) {
t->next = x->next;
delete x;
return 0;
}
return -1;
}
Поскольку тут мы оперируем конкретным списком (его адресует поле head класса), то достаточно одного параметра.