Is it possible to override a function by changing the return type from optional to non-optional in C++?

236 views Asked by At

In C++, I have a parent function whose return type is folly::Optional<int>. My question is: Can we override the function and return int in the derived function?

I know this is doable in Java. For C++, I searched for some documents and saw that C++ allows covariant return type for overriding function. But I didn't find if optional/non-optional is a case of covariant return type.

0

There are 0 answers