I am writing a matrix program, and currently I'm trying to multiply a point and a matrix. I keep getting an error on my objects (result and P). "Expression must have a pointer to an object type" in this function:
//Point Class functions Point Matrix44::operator*(const Point & P){ Point result; for (int i = 0; i < 4; i++) { for (int k = 0; k < 4; k++) { result.element[i][k] = 0; for (int j = 0; j < 4; j++) { result.element[i][k] = element[i][j] * P.element[j][k] + result.element[i][k]; } } } return result; }
My two classes:
//Matrix class class Point; class Matrix44 { private: double element[4][4]; public: Matrix44(void); Matrix44 transpose(void) const; friend istream& operator>>(istream& s, Matrix44& t); friend ostream& operator<<(ostream& s, const Matrix44& t); Matrix44 operator *(Matrix44 b); Point operator*(const Point & P); }; //Point class class Point { double element[4]; friend class Matrix44; public: Point(void) { element[0] = element[1] = element[2] = 0; element[3] = 1; } Point(double x, double y, double z){ element [0]=x; element [1]=y; element [2]=z; element [3]=1; } };
source share