title: How to use std::for_each?
body: <p>Is it possible to use std::for_each or anything else like that ? <br></p>
  
  <pre><code>#include &lt;list&gt;
  #include &lt;algorithm&gt;
  
  // Class declaration
  //
  struct Interface
  {
     virtual void run() = 0;
  };
  
  struct A : public Interface
  {
     void run() { std::cout &lt;&lt; "I run class A" &lt;&lt; std::endl; }
  };
  
  struct B : public Interface
  {
     void run() { std::cout &lt;&lt; "I run class B" &lt;&lt; std::endl; }
  };
  
  // Main
  //
  int main()
  {
     // Create A and B
     A a;
     B b;
  
     // Insert it inside a list
     std::list&lt;Interface *&gt; list;
     list.push_back(&amp;a);
     list.push_back(&amp;b);
  
     // Then execute a func with for_each without recreate a func which call Interface::run() 
     std::for_each(list.begin(), list.end(), run);
  
     return 0;
  }
  </code></pre>
  
  <p>Edit :
  My question is : How can I call each run() member function inside a loop using algorithm or a more simply a C++ way without using iterators...</p>