 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
The
simple syntactic change of adding the virtual
|
|
|
keyword
to the declaration of statement has significantly
|
|
changed
the output.
|
|
|
| • |
In
this example, the member function statement is a
|
|
|
virtual
function. It is defined in the base class and is
|
|
|
overridden
in the derived classes.
|
|
|
| • |
Notice
that the signature and return types are the same.
|
|
|
Also
notice that the keyword virtual only occurs in the
|
|
|
base
class' definition. It is this declaration that enables
|
|
|
dynamic
binding.
|
|
|
| • |
Finally,
notice that we call the member function
|
|
|
statement
through a pointer or reference.
|
|