title: How does dynamic_cast work?
body: <p>If you had the following:</p>
  
  <pre><code>class Animal{};
  
  class Bird : public Animal{};
  
  class Dog : public Animal{};
  
  class Penguin : public Bird{};
  
  class Poodle : public Dog{};
  </code></pre>
  
  <p>Does <code>dynamic_cast</code> just check if one class is a derived class of another, or if one class is a base class of another?  So if I had:</p>
  
  <pre><code>Bird* bird;
  Animal* animal;
  
  bird = dynamic_cast&lt;Animal*&gt;(bird);
  animal = dynamic_cast&lt;Bird*&gt;(animal);
  </code></pre>
  
  <p><code>bird</code> would now point to an <code>Animal</code> class, so that I can use <code>bird-&gt;some_function();</code> and it will call the function in <code>Animal</code>?  And <code>animal</code> now points to a <code>Bird</code> class, so I can do <code>animal-&gt;some_function();</code> and it will call <code>some_function();</code> in <code>Bird</code>?</p>
  
  <p>I've been trying to figure out how the <code>dynamic_cast</code> works, and the resources I've found online haven't been the most helpful.  If someone can offer other insight into the functionality of <code>dynamic_cast</code> and some instances in which it would be useful, I'd highly appreciate it.</p>