title: How to present gravity in 2D (Euler's method) without using any additional libraries?
body: <p>My last question remains unanswered, but I think I'm kind of on a right way this time.</p>
  
  <p>What I need to achieve is a model of gravity, in 2D plane only. I need to have a class of a celestial body, with positionX, positionY, velocity vector and a mass. I want it to work like that: everytime I add a new body, its mass and initial velocity (if set) have an effect on all the other bodies, affecting their position and velocity accordingly. I have been told that it's best to use a list for that and everytime I create a new object I'll apply a <code>move()</code> method to every other list element. Is that right? (clarified because of <a href="https://stackoverflow.com/users/2899478/o-weisman">o_weisman</a> comment, thanks!)</p>
  
  <p>I've declared the class (not all the variables are there)</p>
  
  <pre><code>   class CBody  
      {  
      protected:  
          double x;  
          double y;  
          double mass;  
      public:  
          void move(double time, list&lt;CBody&gt; CBodyList);  
          CBody();  
          ~CBody();  
      };
  </code></pre>
  
  <p>but I am unable to come up with the right method how to exactly make the new list object's values alter the position (by <code>move()</code> method) of the previous ones and represent it in time.</p>
  
  <p>Do you have any ideas? Basically what I want to achieve is that whenever I add a new object with given values (I'm using <code>rand()</code> right now, but I'll probably use <code>cin&gt;&gt;stuff</code> later) it triggers a <code>move()</code> method inside every previous celestial body and adjusts their position accordingly. The problem is - it's not a fixed state, it's happening all the time, how to define the time exactly?</p>
  
  <p>Big thanks for any clarification!</p>
  
  <p>EDIT: Do I need to decalre the list before passing it as a parameter in method? Above code causes errors in VS2010, saying that <code>C2061: syntax error : identifier 'list'</code> and <code>IntelliSense: list is not a template</code> even though I did <code>#include &lt;list&gt;</code>. What's wrong?</p>