title: static_cast vs dynamic_cast
body: <p>Suppose I'm given a C++ library full of inheritance. I'm given a <code>Base*</code> in a function when I know that it is actually pointing to a <code>Derived</code> object and <code>Derived</code> inherits <code>Base</code>. But I don't know what kind of inheritance it is (public/protected/private). I also don't know if there is any virtual function in the hierarchy.</p>
  
  <p>Given this situation, <strong>without looking into the source code/documentation</strong> of <code>Base</code> and <code>Derived</code>, which cast should I use? Or should I consult the code/documentation first to ensure about polymorphism?</p>
  
  <p><strong>Background</strong></p>
  
  <p>I am writing <code>changeEvent</code> function of <code>QMainWindow</code> in Qt 4.7. The <code>changeEvent</code> function takes <code>QEvent*</code> which I can cast to other type by knowing <code>QEvent::type()</code>. I was wondering if I should use <code>static_cast</code> or <code>dynamic_cast</code>.</p>
  
  <p>Thanks.</p>