title: c++ error using std::accumulate creating Least Common Multiple class
body: <p>I am trying to write a class the calculates the Least Common Multiple:</p>
  
  <p>LeastCommonMultiple.h:</p>
  
  <pre><code>#pragma once
  
  #ifndef LEASTCOMMONMULTIPLE_H
  #define LEASTCOMMONMULTIPLE_H
  
  #include &lt;vector&gt;
  #include &lt;numeric&gt;
  
  class LeastCommonMultiple
  {
  public:
      LeastCommonMultiple(std::vector&lt;int&gt;&amp;);
  
      int GetLcmForVector();
  
  private:
      std::vector&lt;int&gt; &amp;m_list;
  
      int GetGreatestCommonDivisor(int, int);
      int GetLeastCommonMultiple(int, int);
  };
  #endif //! LEASTCOMMONMULTIPLE_H
  </code></pre>
  
  <p>LeastCommonMultiple.cpp</p>
  
  <pre><code>#include "stdafx.h"
  #include "LeastCommonMultiple.h"
  
  LeastCommonMultiple::LeastCommonMultiple(std::vector&lt;int&gt;&amp; list) : m_list(list) 
  {}
  
  int LeastCommonMultiple::GetGreatestCommonDivisor(int a, int b)
  {
      for (;;)
      {
          if (a == 0)
          {
              return b;
          }           
  
          b %= a;
  
          if (b == 0) 
          {
              return a;
          }
  
          a %= b;
      }
  }
  
  int LeastCommonMultiple::GetLeastCommonMultiple(int a, int b)
  {
      int temp = LeastCommonMultiple::GetGreatestCommonDivisor(a, b);
  
      return temp ? (a / temp * b) : 0;
  }
  
  int LeastCommonMultiple::GetLcmForVector()
  {
  //std::accumulate takes first, last, initial value, operation
      int result = std::accumulate(m_list.begin(), m_list.end(), 1, LeastCommonMultiple::GetLeastCommonMultiple);
  
      return result;
  }
  </code></pre>
  
  <p>I am getting the error: </p>
  
  <blockquote>
    <p><em>Error    C3867   'LeastCommonMultiple::GetLeastCommonMultiple': non-standard syntax; use '&amp;' to create a pointer to member   myproject</em>  </p>
  </blockquote>
  
  <p>Before making this code object Oriented I tested it using the <code>GetLcmForVector()</code> function in <code>main()</code> and passing <code>std::accumulate</code> an array and it worked fine.</p>
  
  <p><strong>I have read other questions on this error and the issue was forgetting to add parenthesis at the end of the function</strong> BUT I should not have to do that with <code>LeastCommonMultiple::GetLeastCommonMultiple</code> since it is being used in <code>std::accumulate</code> </p>
  
  <p>I am basing my code off this post:</p>
  
  <p><a href="https://stackoverflow.com/questions/4229870/c-algorithm-to-calculate-least-common-multiple-for-multiple-numbers">C++ algorithm to calculate least common multiple for multiple numbers</a></p>