This code worked fine until I added the rot() function. Yes, it is declared properly in the header file. I replaced all the equation with simple 1.0f values but the same error occurred. That hints to me that it has something to do with declaring Matrix2f rot; ...Does anyone have any clue what the issue is here?
#include "Matrix2f.h"
#include <cmath>
#include <iostream>
#include "Vector2f.h"
Matrix2f::Matrix2f(){
m[0][0]= 1.0f; m[0][1]= 0.0f;
m[1][0]= 0.0f; m[1][1]= 1.0f;
}
Vector2f Matrix2f::rot(float theta, Vector2f vec){
Matrix2f rot;
rot[0][0]= cosf(theta); rot[0][1]= -sinf(theta);
rot[1][0]= sinf(theta); rot[1][1]= cosf(theta);
float tx = ((rot[0][0]*vec.getX())+(rot[0][1]*vec.getY()));
float ty = ((rot[1][0]*vec.getX())+(rot[1][1]*vec.getY()));
return Vector2f(tx, ty);
}
void Matrix2f::printMat(){
std::cout << "| " << m[0][0] << " " << m[0][1] << " |" << std::endl;
std::cout << "| " << m[1][0] << " " << m[1][1] << " |" << std::endl;
}
The error the compiler gives:
|17|error: no match for 'operator[]' in 'rot[0]'|
it gives the same code twice for each line from line 17 through line 21... Any help greatly appreciated :)
operator[]inMatrix2f. That's certainly the problem.