title: Does dynamic_cast really work for multiple inheritance?
body: <p>I wanted to see if it's possible to create "interfaces", inherit them, and then check at runtime if any random class implements that interface. This is what I have:</p>
  
  <pre><code>struct GameObject {
      int x,y;
      std::string name;
  
      virtual void blah() { };
  };
  
  struct Airholder {
     int oxygen;
     int nitrogen;
  };
  
  struct Turf : public GameObject, public Airholder {
     Turf() : GameObject() {
        name = "Turf";
     }
  
     void blah() { };
  };
  
  void remove_air(GameObject* o) {
     Airholder* a = dynamic_cast&lt;Airholder*&gt;(o);
     if(!a) return;
     a-&gt;oxygen   = 0;
     a-&gt;nitrogen = 0;
  };
  </code></pre>
  
  <p>Now, it works. The documentation says that it works, the test example works.. But also, it didn't compile until I added a virtual method to GameObject. The thing is, I really don't know if the feature is intended to be used like that. What made me wonder there is the fact that I have to declare a virtual function for the class I'm checking. But obviously, there is none, the class I'm checking itself has no virtual functions, in fact my whole code has nothing to do with virtual functions, it's an entirely different approach.</p>
  
  <p>So, I guess my question is: If what I'm doing really works, why do I need a virtual function to give my class a vtable? Why can't I declare the class a "runtime type" or something without virtual functions?</p>