title: Iterating over a vector of objects
body: <p>I am trying to iterate over a vector of objects and perform a simple update function which moves the object 1 pixel to the right each time. However, when I run the code, the x value is only changed once.</p>
  
  <p>In source.cpp:</p>
  
  <pre><code> for (int i = 0; i &lt; Screen::SCREEN_WIDTH * Screen::SCREEN_HEIGHT; i++) {
      people.push_back(Person());
  }
  
  for (int i = 0; i &lt; 1; i++) {
      people[i].isAlive = true;
  }
  
  while(true) {
  
   for (Person p : people) {
          if (p.isAlive == true) {
              p.Update(p);
              cout &lt;&lt; p.x &lt;&lt; endl;
              screen.setPixel(p.x, p.y, 255, 0, 0);
          }
          else {
              screen.setPixel(p.x, p.y, 0, 0, 0);
          }
      }
   }
  </code></pre>
  
  <p>In person.cpp</p>
  
  <pre><code> void Person::Update(Person &amp;person) {
        person.x += 1;
  </code></pre>
  
  <p>}</p>
  
  <p>As you can see, i select one person from the array and set them to be alive, and therefor to be drawn. They are drawn every frame, but not updated. Can anyone help me out with this?</p>