Take the following C++ for example.
vector listAnimal;
class Fish : Animal ...
class Mammal : Animal ...
class Bird : Animal ...
I typically create a pure virtual function that each derived class implements to tell you its identity. Example:
enum AnimalType
{
Fish = 0,
Mammal,
Bird
}
class Animal
{
virtual AnimalType GetType() const = 0;
}
...
AnimalType Bird::GetType()
{
return Bird;
}
Then you can do something like this:
if (animal.GetType() == Bird)
{
// ...
}