Seriously, I looked at similar examples, but I still do not get why it is not working. I am having trouble with overloading the = operator.
I get the two following errors:
- error C2955: 'Matrix' : use of class template requires template argument list
- error C2244: 'Matrix::operator =' : unable to match function definition to an existing declaration
May someone please explain what is wrong?
Thanks to all
//Matrix.hpp
template<typename T>
class Matrix
{
public:
Matrix(int numberRows, int numberColumns);
~Matrix();
void asgValue(T value, int row, int column);
T getValue(int row, int column);
Matrix<T>& operator= (const Matrix<T>& rhs);
friend Matrix<T>& operator+ (const Matrix<T>& lhs, const Matrix<T>& rhs);
private:
T **twoDarray;
int nbrRows;
int nbrColumns;
};
#include "Matrix.inl"
//Matrix.inl
//Matrix<T>& Matrix<T>::operator= (const Matrix<T>& rhs)
template<typename T>
Matrix<T>& Matrix::operator= (const Matrix<T>& rhs)
{
for (int i = 0; i < nbrRows; i++)
{
for (int j = 0; j < nbrColumns; j++)
{
twoDarray[i][j] = rhs.twoDarray[i][j];
}
}
return *this;
}