title: Calling a member function of every element of a C++ vector
body: <p>Suppose there is a vector of class objects.</p>
  
  <pre><code>vector&lt;Object1&gt; vec;
  </code></pre>
  
  <p>Say, <code>Object1</code> has a member function <code>void foo(Object2*)</code>.</p>
  
  <p>I want to do the following:</p>
  
  <pre><code>for(int i=0; i&lt;vec.size(); i++) {
      vec[i].foo(obj2);
  }
  </code></pre>
  
  <p>How can this be done without using an explicit loop?</p>