C++ has both return type polymorphism and inheritance. What it doesn't have is the kind of type inference that Haskell has. Its type inference is very limited.
template<typename T>
T my_construct() { T result; return result; }edit: you get pseudo call-by-name as a bonus.
struct PolyReturn {
const int value;
operator int() const { return value; }
operator bool() const { return value > 0; }
};
https://cppinsights.io/s/f0b9976f