 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
In
order to implement a virtual friend, we must
|
|
|
implement
a virtual helper member function that
|
|
|
performs
the operation that we want and then call it from
|
|
the
non-member function.
|
|
|
| • |
We
must be careful to declare the object for which we
|
|
|
want
polymorphic behavior to be a pointer or a reference
|
|
in
the helper function.
|
|
|
| • |
If
the object is passed by value to the non-member
|
|
|
function
then dynamic binding cannot be used because
|
|
|
we
have an object and not a pointer or reference.
|
|
|
| • |
It is
best to make the helper functions protected or
|
|
|
private
in the base class and in all derived classes and
|
|
|
then
the non-member function a friend of the class.
|
|