Introduction to OOP | Chapter 16: Overriding : | next | previous | audio | real | text |
class Parent { void test (covar : Mammal, contravar : Mammal) : boolean } class Child extends Parent { void test (covar : Cat, contravar : Animal) : boolean }While appealing, this idea runs into trouble with the principle of substitution.
Parent aValue = new Child(); aValue.text(new Dog(), new Mammal()); // is this legal??