Is a Cow an Animal?

Is a Cow an Animal? An interesting discussion of covariance. An Animal class has an eat method that takes a food as an argument. A Cow class inherits from animal and overrides the eat method to take a vegetableFood argument. This is covariance. The problem is when you have an Animal instance of type Cow and you try to feed it some meat...

Permalink: http://blog.iandavis.com/2002/05/is-a-cow-an-animal/

Other posts tagged as object-oriented, technology

Earlier Posts