In which cases I should use polymorphism ?
I know that if we create classes mammal, cat and a dog like:
class mammal
{
...
virtual void Run();
};
class cat : public mammal
{
...
Run();
};
class dog : public mammal
{
...
Run();
};
void main()
{
mammal *pMammal1;
mammal *pMammal2;
cat *pCat = new cat();
dog *pDog = new dog();
pMammal1 = pCat;
pMammal2 = pDog;
}
we can access cat and dog trough mammal. But what is the use of this, when we can implement this ? Why not just put Run() inside cat and dog without having mammal ?