title: for_each usage in C++
body: <pre><code>#include &lt;list&gt;
  #include &lt;algorithm&gt;
  
  class Abstract
  {
      //contains a pure virtual function
  };
  
  class Mock
  {
  public:
     Mock();
  
   ~Mock()
   {
      std::for_each(m_abs_list.begin(), m_abs_list.end(), my_func);    
   } 
  
   void my_func(Abstract *ele){delete ele;} 
  
  private:
     std::list &lt;Abstract *&gt; m_abs_list;
  };
  </code></pre>
  
  <p>Basically, I am trying to call the destructor for each <code>Abstract</code> object in the <code>m_abs_list</code>. This can be easily achieved by a <code>for</code> loop. But I am trying to used <code>for_each</code> in this context.</p>
  
  <p>On compilation I get error:</p>
  
  <pre><code>/usr/include/c++/4.2/bits/stl_algo.h: In function '_Function std::for_each(_InputIterator, _InputIterator, _Function) [with _InputIterator = std::_List_iterator&lt;Abstract *&gt;, _Function = void (Mock::*)(Abstract *)]'
  
  /usr/include/c++/4.2/bits/stl_algo.h:159: error: must use '.*' or '-&gt;*' to call pointer-to-member function in '__f (...)'.
  </code></pre>
  
  <p>How do i get around the compilation error ?</p>