Contents Up << >>
What is a "virtual member function"?
A virtual function allows derived classes to replace the implementation
provided by the base class. The compiler ensures the replacement is
always called whenever the object in question is actually of the derived class,
even if the object is accessed by a base pointer rather than a derived
pointer. This allows algorithms in the base class to be replaced in the derived
class, even if users don't know about the derived class.
Note: the derived class can partially replace ("override") the base
class method (the derived class method can invoke the base class version if
desired).