I have a Matrix4 class derived from / extension of the Matrix base class (template class). Template class methods are declared and defined in the same header file.
I just copied the part of the Matrix4 class that gives the error. The same error occurs on lines 10 and 13. I do not see any missing variables or arguments. I tried to pick up the brackets, but to no avail.
I was looking for the key to what I can do wrong, but I did not find anything useful in such matters on this site ... I would really appreciate help.
Matrix4 class throwing an error:
template<typename T>
class Matrix4 : public Matrix<T, 4>
{
public:
Matrix4() { }
inline Matrix4 InitOrthographic(T left, T right, T bottom, T top, T near, T far)
{
const T width = (right - left);
const T height = (top - bottom);
const T depth = (far - near);
(*this)[0][0] = T(2)/width; (*this)[1][0] = T(0); (*this)[2][0] = T(0); (*this)[3][0] = -(right + left)/width;
(*this)[0][1] = T(0); (*this)[1][1] = T(2)/height; (*this)[2][1] = T(0); (*this)[3][1] = -(top + bottom)/height;
(*this)[0][2] = T(0); (*this)[1][2] = T(0); (*this)[2][2] = T(-2)/depth; (*this)[3][2] = -(far + near)/depth;
(*this)[0][3] = T(0); (*this)[1][3] = T(0); (*this)[2][3] = T(0); (*this)[3][3] = T(1);
return *this;
}
Base matrix class:
template<typename T, unsigned int D>
class Matrix
{
public:
Matrix() { }
virtual ~Matrix() { }
Matrix(const Matrix& other) { *this = other; }
inline Matrix InitIdentity();
inline Matrix InitTranslation(const Vector<T, D-1>& r);
inline Matrix& operator=(const Matrix& rhs);
inline Matrix operator*(const Matrix<T,D>& r) const;
inline const T* operator[](int index) const { return m[index]; }
inline T* operator[](int index) { return m[index]; }
private:
T m[D][D];
};
There are no errors in the base class "Matrix", only in the derived class "Matrix4".
, Youtube Tutorial xD