title: Virtual inheritance C++ and boost python
body: <p>In a game I'm working on I have two C++ classes (ICollidable and Sprite) which both virtually inherit another C++ class called Object, for its properties Position and Size. I have these three classes exposed to python with boost python. The Player class constructor in python looks like this for example:</p>
  
  <pre><code>class Player(Game.ICollidable, Game.Sprite, Game.IKeyboardListener, Game.IEntity):
      def __init__(self):
          Game.IKeyboardListener.__init__(self)
          Game.IEntity.__init__(self)    
          Game.ICollidable.__init__(self)
          Game.Sprite.__init__(self)
  </code></pre>
  
  <p>The problem is that when the Sprite <strong>init</strong> comes before ICollidable's <strong>init</strong> the Sprite position doesn't work correctly, and I cant reposition the sprite on the screen. I think whats happening is that there are separate instances of the position from Sprite and ICollidable which is what I thought would happen before I made the ICollidable class.</p>
  
  <p>I've tried a variety of things to try and solve this problem and scoured the internets to find solutions to a problem like this one but I've come up empty handed. Any advice, solutions or hints would be greatly appreciated. </p>
  
  <p><strong>Edit:</strong></p>
  
  <p>These are the python bindings to my C++ classes:</p>
  
  <pre><code>class_&lt;Object&gt;("GameObject")
      .def_readwrite("Pos", &amp;Object::pos)
      .def_readwrite("Size",&amp;Object::size)
  ;
  class_&lt;Sprite, bases&lt;Object&gt;&gt;("Sprite", init&lt;&gt;())
      // Sprite(TexID, Pos)
      .def(init&lt;GLuint, glm::vec2&gt;())
      // ----------------------------
      .def_readwrite("TexId", &amp;Sprite::texid)
  ;
  class_&lt;ICollidableWrap, bases&lt;Object&gt;,boost::noncopyable&gt;("ICollidable", init&lt;&gt;())
      //.def("Pos", &amp;ICollidable::Object::pos)
      .def("Test", pure_virtual(&amp;ICollidable::Test))
      .def("OnCollision",pure_virtual(&amp;ICollidable::OnCollision))
  ;
  </code></pre>