Introduction to OOP: Chapter 12: Implications of Inheritance [next] [previous] [audio] [real] [text]

RTTI

Recent addition to C++ is the Run Time Type Identification system - allows a type of cast that is checked at run time.

aBall = ....;
aBlackBall = dynamic_cast(aBall);
if (aBlackBall) { // it was a black ball
	}
else { // it was not a black ball
	}
but only works if the class Ball has at least one virtual method.
Intro OOP, Chapter 12, Slide 22