Hello everyone,
I don't have much experience with C++ and it has been a while since I have last used it. Right now I am writing my own class for quaternions. My problem which I cannot figure out is what is wrong with the operator overload shown below... No matter what I try and change I more or less recieve multiples of the same error:
invalid operands of types `double*' and `double*' to binary `operator*'
I've looked around and don't really understand what my problem is... Any help is much appreciated.
Thanks in advance.
class CQuaternion{
public:
// Constructors
CQuaternion(double,double,double,double);
CQuaternion();
// Desctructors
~CQuaternion();
CQuaternion* operator*(CQuaternion&);
void conjugate ();
void print () ;
private:
double *w, *x, *y, *z;
};
CQuaternion::CQuaternion (double a, double b, double c, double d) {
*w = a;
*x = b;
*y = c;
*z = d;
}
CQuaternion::CQuaternion () {
w = new double;
x = new double;
y = new double;
z = new double;
*w = 0;
*x = 0;
*y = 0;
*z = 0;
}
CQuaternion::~CQuaternion () {
delete w;
delete x;
delete y;
delete z;
}
void CQuaternion::conjugate() {
*x = -(*x);
*y = -(*y);
*z = -(*z);
}
CQuaternion* CQuaternion::operator* (CQuaternion& param) {
CQuaternion* temp;
temp->w = (this->w)*param.w - (this->x)*param.x - (this->y)*param.y - (this->z)*param.z;
temp->x = (this->w)*param.x + (this->x)*param.w + (this->y)*param.z - (this->z)*param.y;
temp->y = (this->w)*param.y - (this->x)*param.z + (this->y)*param.w + (this->z)*param.x;
temp->z = (this->w)*param.z + (this->x)*param.y - (this->y)*param.x + (this->z)*param.w;
return (*temp);
}