C++ covariance in parameters

The return type is permissible since derived inherits from base, but the function parameter can’t work – not all base instances will be a derived also. What’s supposed to happen in the cases where func is called on a pointer to base with a parameter that’s not a derived? The most derived implementation isn’t callable.

Leave a Comment