Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. if (x == begin()) {
  2. cout << "Удалить первый узел";
  3. }
  4. for (Node* i = begin(); i->next != end(); i=i->next) {
  5. Node* tmp = i->next;
  6. if (tmp && tmp == x) {
  7. i->next = i->next->next;
  8. delete tmp;
  9. }
  10. }
  11.  
  12. avp@avp-ubu1:hashcode$ g++ huxilist.cpp
  13. huxilist.cpp: In copy constructor ‘List::List(const List&)’:
  14. huxilist.cpp:16:47: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::begin()’ discards qualifiers [-fpermissive]
  15. huxilist.cpp:16:60: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::end()’ discards qualifiers [-fpermissive]
  16. huxilist.cpp: In member function ‘List& List::operator=(const List&)’:
  17. huxilist.cpp:37:27: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::begin()’ discards qualifiers [-fpermissive]
  18. huxilist.cpp:37:40: error: passing ‘const List’ as ‘this’ argument of ‘List::Node* List::end()’ discards qualifiers [-fpermissive]
  19. huxilist.cpp: In function ‘int main()’:
  20. huxilist.cpp:114:9: error: ‘List_m’ has not been declared
  21. huxilist.cpp:114:23: error: ‘it1’ was not declared in this scope
  22. huxilist.cpp:114:29: error: ‘listfile’ was not declared in this scope
  23. avp@avp-ubu1:hashcode$
  24.  
  25. int delete_node (Node *x) {
  26. if (!x || !head)
  27. return -1;
  28. if (x == head) {
  29. head = x->next;
  30. delete x;
  31. return 0;
  32. }
  33. for (Node *t = head; t; t = t->next)
  34. if (t->next == x) {
  35. t->next = x->next;
  36. delete x;
  37. return 0;
  38. }
  39. return -1;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement