Hi,
I have just started learning classes and I have to make a matrix class. I know matrix math so that is not an issue, basically I have an h and cpp with function names and parameters and just have to define them. My problem is that Im stuck at the first one as I don't know how to use the parameters I am supposed to correctly. I'll post the h and what I am trying to do with the first function. The Exercises::Multiply is something that is setup already and I have no access to so I have know idea what is in it, basically it tests if what I have is correct or not. Im sure I am doing something completely stupid but I am a newb, I know the parameters arent arrays but I have no idea how else to use them in this function. Anyway if anyone can help me with this one i'll finally be able to work on the rest.
These are the errors I get:
error C2676: binary '[' : 'CMatrix' does not define this operator or a conversion to a type acceptable to the predefined operator
error C2679: binary '=' : no operator found which takes a right-hand operand of type 'int' (or there is no acceptable conversion)
could be 'CMatrix &CMatrix::operator =(const CMatrix &)'
1> while trying to match the argument list '(CMatrix, int)'
Sorry for the length and thanks in advance.
.h
#ifndef __MATRIX_H__
#define __MATRIX_H__
class CMatrix
{
public:
float m_fMatrix[4][4];
};
#endif // __MATRIX_H__
.cpp
#include <cmath>
#include "matrix.h"
void
Exercises::Multiply(const CMatrix& _rLHS, const CMatrix& _rRHS, CMatrix& _rResult)
{
for (int i = 0; i < 4; i++)
{
for (int j = 0; j < 4; j++)
{
_rResult = 0;
for (int k = 0; k < 4; k++)
{
_rResult += m_fMatrix[i][k] * m_fMatrix[k][j];
}
m_fMatrix[i][j] = _rResult;
}
}
}