I am trying to overload the =, + +=
operators and the first two worked fine but the operator+=()
function is producing an error.
Here is the code for the three:
Overloading '=' operator
inline vec3& operator = (vec3& ob) {
mX = ob.getX();
mY = ob.getY();
mZ = ob.getZ();
return *this;
}
Overloading '+' operator
vec3 vec3::operator + (const vec3& ob) {
vec3 vec(mX + ob.getX(), mY + ob.getY(), mZ + ob.getZ());
return vec;
}
Overloading '+=' operator
vec3& vec3::operator += (const vec3& obj) {
*this = *this + obj;
return *this;
}
Error
binary '=': no operator found which takes a right-hand operand of type 'vec3'