Say I define an interface IAnimal
which has a pure virtual (abstract) method called eat like this:
class IAnimal
{
virtual void eat(Food*) = 0;
};
In the future I inherit form IAnimal
and create different animals. and eventually I find out that some animals need not only food to eat but also other things. Say in my context, (it is easy to imagine it is a game), Dog
s can eat if there is a Food
and a Plate
. Man
s can eat if there is a Food
, Plate
, Table
and Chair
. Does this mean that it is wrong to use inherit from IAnimal
? Can we say that Dog
and Man
are not animals as you can not use them interchangeably.