title: C++ Iteration over class pointers using std::vector
body: <p>I am trying to Iterate over a vector using pointers
  I have a vector called:</p>
  
  <pre><code> std::vector&lt;GameObject*&gt; objects;
  </code></pre>
  
  <p>and a load of functions like these:</p>
  
  <pre><code>void Game::update()
   {
      std::vector&lt;GameObject*&gt;::iterator itr;
      for( itr = objects.begin();itr &lt; objects.end();++itr)
      {
          itr-&gt;update();//I need to call a abstract function in the GameObject Class
      }
   }
   Game::~Game()
   {
  
      delete ball;
      delete player;
   }
  Game::Game()
  {
      ball = new GOBall(800/2 - GOBall::SIZE/2,600/2 - GOBall::SIZE/2);
      player = new GOPlayer(0, 600/2 - GOPlayer::SIZEY/2,ball);
      objects.push_back(ball);
      objects.push_back(player);
  }
  </code></pre>
  
  <p>As you can see I am trying to iterate in a way that still allows me to call the function and also parse the polymorphistic class into other polymorphistic classes(hence the reason its declared before being parsed into the vector), what I keep getting is error:</p>
  
  <blockquote>
    <p>C2839: invalid return type 'GameObject *const *' for overloaded 'operator ->'</p>
  </blockquote>
  
  <p>and error:</p>
  
  <blockquote>
    <p>C2039: 'update' : is not a member of 'std::_Vector_const_iterator&lt;_Ty,_Alloc>'</p>
  </blockquote>
  
  <p>which tells me i cant call <code>ball-&gt;update()</code> or <code>player-&gt;update()</code> through the iterator, so how do I do it?</p>