Use std::list to remove element from user entered string

If this function uses a user-entered string ISBN, how can I find the element in the linked list and delete the book? I am required to only use public member functions from the list library (#include <list>) Each book contains a title (string), price (double), quantity (int), and ISBN (string).

1
2
3
4
  void books::delete_item(string ISBN) {
    // Code

  }
> how can I find the element in the linked list
go through each element on your container
¿is the current one the one you are searching for? In that case you are done, otherwise «discard» that element
at the end, your container will be empty (the element was not there) or you find it.

> delete the book
list is an ordered container, so make find() return the position of the element that you wan to eliminate, then call list::erase()
Topic archived. No new replies allowed.