title: C++ Vector iterate over abstract class
body: <p>Background info:
  Me and a couple of friends are building this platform game in C++ with the help och sfml and box2d for a school assignment.
  One of the requirements is that we follow the &quot;MVC pattern&quot;.</p>
  <p>We have created classes like Bullet and Character for the model. And BulletView and CharacterView (both inherits sf::Drawable which is an abstract class) for the view.</p>
  <p>Instead of duplicating code for drawing and have two methods drawBullets and drawCharacter like this</p>
  <pre><code>void WorldView::drawBullets()
  {
      std::vector&lt;BulletView*&gt;::iterator it;
      for ( it = bullets.begin() ; it &lt; bullets.end(); it++ )
          window-&gt;draw(**it);
  }
  
  void WorldView::drawCharacters()
  {
      std::vector&lt;CharacterView*&gt;::iterator it;
      for ( it = characters.begin() ; it &lt; characters.end(); it++ )
          window-&gt;draw(*it);
  }
  </code></pre>
  <p>I would like a more generic method using polymorhism which would look something like this:</p>
  <pre><code>void WorldView::drawVector(const std::vector&lt;sf::Drawable*&gt;&amp; vector)
  {
      std::vector&lt;sf::Drawable*&gt;::iterator it;
      for ( it = vector.begin() ; it &lt; vector.end(); it++ )
          window-&gt;draw(**it);
  }
  </code></pre>
  <p>The bulletView vector is declared like this:</p>
  <pre><code>std::vector&lt;BulletView*&gt; bullets;
  </code></pre>
  <p>Can't get this to work though. And I'm kind of new to C++ so please have mercy! I've tried searching but have not found very specific answers.</p>
  <p>Errors I get while compiling.</p>
  <blockquote>
  <p>Error  8   error C2679: binary '=' : no operator found which takes a right-hand &gt;operand of type 'std::_Vector_const_iterator&lt;_Myvec&gt;' (or there is no acceptable &gt;conversion) c:\users\niklas\multiplaya\sfml test\sfml test\view\worldview.cpp   409 &gt;1  SFML_Test</p>
  <p>Error  7   error C2664: 'mp::WorldView::drawVector' : cannot convert parameter 1 from &gt;'std::vector&lt;_Ty&gt;' to 'const std::vector&lt;_Ty&gt; &amp;'    c:\users\niklas\multiplaya\sfml &gt;test\sfml test\view\worldview.cpp  402 1   SFML_Test</p>
  </blockquote>