C++ virtual function return type
In some cases, yes, it is legal for a derived class to override a virtual function using a different return type as long as the return type is covariant with the original return type. For example, consider the following: class Base { public: virtual ~Base() {} virtual Base* clone() const = 0; }; class Derived: … Read more