These two files show the covariant problem. See problem.cpp to know what it is and see kovariant.cpp for a dynamic solution. There are better solutions with higher-order subtyping (templates). return.cpp shows how you can return covariant parameters. But this does not work with templates, see templated.cpp. Why it does not work is shown in the reduced example level.cpp (without templates).