Introduction to OOP: Chapter 10: Subclasses and Subtypes [next] [previous] [audio] [real] [text]

Reverse polymorphism

Polymorphism says we can assign a value from a child class to an instance of the parent class, but can this assignment then be reversed? Under what conditions?

	pet : Mammal;
	fido : Dog;
	felice : Cat;
	pet := fido;	// legal
	fido := pet;	// is this legal? 

This is known as the problem of reverse polymorphism.
Intro OOP, Chapter 10, Slide 8