title: Iterating through a list of points in C++
body: <p>I have a point3 struct that takes 3 floats x, y, z (3-D space coordinates).</p>
  
  <p>I'm trying to write a function that translates the x, y, z values of each element in a list of points.</p>
  
  <p>I'm new to C++ so I don't think I wrote the iterator correctly, can anyone help clarify how to iterate down a list and modify components of each element in the list?</p>
  
  <p>I looked at this post <a href="https://stackoverflow.com/questions/1355531/c-how-to-loop-through-a-list-of-structs-and-access-their-properties">C++ How to loop through a list of structs and access their properties</a> and thought this answered my problem, but the solution didn't work.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>//Translates the face by dx, dy, dz coordinates
  list&lt;point3&gt; translateFace(list&lt;point3&gt; lop, float dx, float dy, float dz)
  {
      list&lt;point3&gt;::iterator iter;
  
      for (iter = lop.begin() ; iter != lop.end(); iter++){
          iter-&gt;x - dx;
          iter-&gt;y - dy;
          iter-&gt;z - dz;
      }
     return lop;
  }
  </code></pre>
  
  <p>I also tried the solution suggested in the link above, still didn't work. Should <em>return lop</em> be inside or outside the for loop? Should I be returning something other than lop?</p>
  
  <pre><code>for (iter = lop.begin() ; iter != lop.end(); iter++){
      (*iter).x - dx;
      (*iter).y - dy;
      (*iter).z - dz;
      }
  return lop;
  </code></pre>