Check the type of derived class
<p>In my program I have a class named Entity. Another class Invader inherits Entity. Since I want to have 4 different kinds of invaders, I declare classes Invader1, Invader2, Invader3 and Invader4 which inherit from Invader. Now I declare a Entity pointer type vector to store all Invaders like:</p>

<pre><code>entities.push_back(new Invader4());
entities.push_back(new Invader3());
entities.push_back(new Invader2());
entities.push_back(new Invader1());
entities.push_back(new Invader0());
</code></pre>

<p>When I check the type of the element in entities at runtime, say</p>

<pre><code>typeid(*entities-&gt;at(index)) 
</code></pre>

<p>It may return one of the 4 kinds of invaders. In entities there are also other objects which inherit Entity. So i just want to check if the type of the object is Invader or not, I don't want to know if it is Invader1, Invader2, etc.</p>

<p>How I can achieve this?</p>
