<<< Implementing prototypes | Index | Pattern Three: Adapter >>> |
Suppose class A declares member function A::f( ) as a virtual function, and class B derives from A.
Ordinarily, return types are allowed to vary between overrides of f( ).
However, for virtual functions the rules are more complex,
that is, B may override f( ) with a different return type, if:
The function B::f( ) returns a reference or pointer to a class of some type T,
and A::f( ) returns a pointer or a reference to an unambiguous direct or indirect base class of T.
The const qualification of the pointer or reference returned by B::f( ) has the same,
or less const qualification of the pointer or reference returned by A::f( ).
The return type of B::f( ) must be complete at the point of declaration of B::f( ),
or it can be of type B.
<<< Implementing prototypes | Index | Pattern Three: Adapter >>> |