I need help on finding the problem using a custom c++ class to manage 3D positions. Here is the relevant code from the class
Punto operator+(Punto p){
return Punto(this->x + p.x, this->y + p.y, this->z + p.z);
}
Punto operator+(Punto *p){
return Punto(this->x + p->x, this->y + p->y, this->z + p->z);
}
Punto operator-(Punto p){
return Punto(this->x - p.x, this->y - p.y, this->z - p.z);
}
Punto operator-(Punto *p){
return Punto(this->x - p->x, this->y - p->y, this->z - p->z);
}
Punto *operator=(Punto p){
this->x = p.x;
this->y = p.y;
this->z = p.z;
return this;
}
Punto *operator=(Punto *p){
this->x = p->x;
this->y = p->y;
this->z = p->z;
return this;
}
I'm using it here like this:
p = fem->elementoFrontera[i]->nodo[0] - fem->elementoFrontera[i]->nodo[1];
Where nodo[i] is a Punto*, and it compiles fine, but when I try to do:
p = fem->elementoFrontera[i]->nodo[0] + fem->elementoFrontera[i]->nodo[1];
The compiler says:
In member function
void mdTOT::pintarElementosFrontera()': error: invalid operands of types
Punto*' andPunto*' to binary
operator+'