title: How to fix pure virtual function called runtime error?
body: <p>I understand why I am getting the error I am getting (pure virtual function called). I am trying to call pure virtual functions from within the destructor of my base class shown below. However, I do not know how to rework my code to prevent this from happening. Here are the base and derived classes (the relevant portions anyway):</p>
  
  <p>Base class:</p>
  
  <pre><code>TailFileManager::TailFileManager(const std::string &amp;filename, const int fileOpenPeriod_ms)
  : m_Stop(false)
  {
      m_WorkerThread.reset(new boost::thread(boost::bind(&amp;TailFileManager::TailFile, this, filename, fileOpenPeriod_ms)));
  }
  
  TailFileManager::~TailFileManager()
  {
      m_Stop = true;
      m_WorkerThread-&gt;join();
  }
  
  void TailFileManager::TailFile(const std::string &amp;filename, const int fileOpenPeriod_ms)
  {
      std::ifstream ifs(filename.c_str());
  
      while (! ifs.is_open())
      {
          boost::this_thread::sleep(boost::posix_time::milliseconds(fileOpenPeriod_ms));
      ifs.open(filename.c_str());
      }
  
      ifs.seekg(0, std::ios::end);
  
      while (! m_Stop)
      {
          ifs.clear();
  
          std::string line;
  
          while (std::getline(ifs, line))
          {
              OnLineAdded(line);
          }
  
          OnEndOfFile();
      }
  
      ifs.close();
  }
  </code></pre>
  
  <p>Derived class:</p>
  
  <pre><code>ETSLogTailFileManager::ETSLogTailFileManager(const std::string &amp;filename, const int heartbeatPeriod_ms)
  : TailFileManager(filename, heartbeatPeriod_ms),
    m_HeartbeatPeriod_ms(heartbeatPeriod_ms),
    m_FoundInboundMessage(false),
    m_TimeOfLastActivity(0)
  {
  }
  
  ETSLogTailFileManager::~ETSLogTailFileManager()
  {
  }
  
  void ETSLogTailFileManager::OnLineAdded(const std::string &amp;line)
  {
      // do stuff...
  }
  
  void ETSLogTailFileManager::OnEndOfFile()
  {
      // do stuff...
  }
  </code></pre>