Virtual methods are useful when you need a method to be sticky through
a subclass-to-superclass pointer cast. In other words, use a virtual
method when the method should be object specific at run-time, and not
pointer-type specific at compile time.
In our example, a CISStudent
object always take a test as a
CIS Student. Regardless of the compile time context, a CISStudent
object always uses the CISStudent::takeTest
method.
Copyright © 2006-10-05 by Tak Auyeung