title: Checking if a pointer points to a particular class C++
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/351845/finding-the-type-of-an-object-in-c">Finding the type of an object in C++</a>  </p>
  </blockquote>
  
  
  
  <p>I have a question with checking pointers to see if they conform to a particular derived class and take necessary action. </p>
  
  <p>Lets say I currently have 2 derived classes <code>DerivedClass1</code> and <code>DerivedClass2</code> and the base class <code>BaseClass</code>. I would like to check the following action.</p>
  
  <p><code>Ptr&lt;BaseClass&gt; ptr;</code></p>
  
  <p><code>if (ptr points to DerivedClass1)</code>
  <code>{</code>
  action1
  <code>}</code>
  else
  <code>{</code>
  action2
  <code>}</code></p>
  
  <p>How do I check for ptr points to a particular DerivedClass?</p>