Return Type
Covariant Return Type
First heard from Ross Evans in CS247.
They can be used for Function Overrides, where we have different return types to achieve some Polymorphism.
However, covariant return types must be pointers or references.
This doesn’t work for example, because the return type is different
But this works, because Derived*
is a child of a Base*
Links