title: Use of a functor on for_each
body: <p>Why does the <code>for_each</code> call on functor doesn't update <code>sum::total</code> at the end?</p>
  
  <pre><code>struct sum
  {
      sum():total(0){};
      int total;
  
      void operator()(int element) 
      { 
         total+=element; 
      }
  };
  
  int main()
  {
      sum s;
  
      int arr[] = {0, 1, 2, 3, 4, 5};
      std::for_each(arr, arr+6, s);
      cout &lt;&lt; s.total &lt;&lt; endl; // prints total = 0;
  }
  </code></pre>