I'm currently working on a project about browser histories. I'm using the STL's list implementation to keep track of the different websites. I have most of it figured out but I can't seem to resolve the error:
Screenshot; cannot dereference end list iterator.

The website data is contained within my Site objects.
class BrowserHistory {
   private:
      list<Site> history;
      list<Site>::iterator current = history.begin();
   public:
      void visitSite(string, size_t)
      void backButton();
      void forwardButton();
      void readFile(string);
};
void BrowserHistory::visitSite(string x, size_t y)
{
   while (current != history.end()) {
       history.pop_back();
   }
   history.push_back({ x, y });
   current++;
}
void BrowserHistory::backButton()
{
   if (current != history.begin())
       current--;
}
void BrowserHistory::forwardButton()
{
   if (current != history.end())
       current++;
}
void BrowserHistory::readFile(string filename)
{
   string action, url;
   size_t pageSize;
   ifstream dataIn;
   dataIn.open(filename);
   while (!dataIn.eof()) {
       dataIn >> action;
       if (action == "visit") {
           dataIn >> url >> pageSize;
           history.push_back({ url, pageSize });
           current++;
       }
       if (action == "back") {
           current--;
       }
       if (action == "forward") {
           current++;
       }
   }
   dataIn.close();
}
Can anyone explain to me what's wrong? Thanks in advance for any help.
 
     
    