title: C++ STL List calculate average
body: <p>I have to correct some C++/STL code. Unfortunately I have very little C++ experience and know nothing about STL. Nevertheless I finished most of it, but the function below is still giving me problems:</p>
  
  <p>C++ source:</p>
  
  <pre><code>double MyClass::CalculateAvg(const std::list&lt;double&gt; &amp;list)
  {
      double avg = 0;
      std::list&lt;int&gt;::iterator it;
      for(it = list-&gt;begin(); it != list-&gt;end(); it++) avg += *it;
      avg /= list-&gt;size();
  }
  </code></pre>
  
  <p>C++ header:</p>
  
  <pre><code>static double CalculateAvg(const std::list&lt;int&gt; &amp;list);
  </code></pre>
  
  <p>It's most likely meant to calculate the average value from a list, but it complies with a lot of errors. I tried to search for a solutions on the web, but I couldn't find anything. I would be glad if someone could help me out.</p>
  
  <p>Update:
  Thank you for your quick replies. The accepted answer solved all my problems.</p>