Код ошибки.
In file included from ./Machinarium/Classes/Geometry/Vector2.cpp:1:
./Machinarium/Classes/Geometry/Vector2.h: In instantiation of ‘class Vector2D<int>’:
./Machinarium/Classes/Geometry/Vector2.cpp:102:16: required from here
./Machinarium/Classes/Geometry/Vector2.h:8:23: error: invalid covariant return type for ‘Vector2D<T> Vector2D<T>::add_by_number(T) [with T = int]’
8 | #define DVector(name) Vector ## name ## D
./Machinarium/Classes/Geometry/Vector2.cpp:37:15: note: in expansion of macro ‘DVector’
37 | DVector(2)<T> DVector(2)<T>::add_by_number(T value)
| ^~~~~~~
In file included from ./Machinarium/Classes/Geometry/Vector2.h:10,
from ./Machinarium/Classes/Geometry/Vector2.cpp:1:
./Machinarium/Classes/Geometry/../../Interfaces/IVector.hpp:33:15: note: overridden function is ‘C IVector<C, T>::add_by_number(T) [with C = Vector2PD<int>; T = int]’
33 | virtual C add_by_number(T) = 0;
| ^~~~~~~~~~~~~
Декларация в классе
template<class C, typename T> class IVector {
public:
...
virtual C add_by_number(T) = 0;
...
template<typename T>
class DVector(2) : public DVector(2P)<T>, public IVector<DVector(2P)<T>, T>
{
public:
...
virtual DVector(2) add_by_number(T);
...
template<typename T>
DVector(2)<T> DVector(2)<T>::add_by_number(T value)
{
return DVector(2)<T>(this->x() + value, this->y() + value);
}
Почему возникает ошибка?