I have the following function (which worked in Visual Studio):
bool Plane::contains(Vector& point){
return normalVector.dotProduct(point - position) < -doubleResolution;
}
When I compile it using g++ version 4.1.2 , I get the following error:
Plane.cpp: In member function âvirtual bool Plane::contains(Vector&)â:
Plane.cpp:36: error: no matching function for call to âVector::dotProduct(Vector)â
Vector.h:19: note: candidates are: double Vector::dotProduct(Vector&)
So as you can see, the compiler thinks (point-position) is a Vector but it's expecting Vector&.
What's the best way to fix this?
I verified that this works:
Vector temp = point-position;
return normalVector.dotProduct(temp) < -doubleResolution;
But I was hoping for something a little bit cleaner.
I heard a suggestion that adding a copy constructor might help. So I added a copy constructor to Vector (see below), but it didn't help.
Vector.h:
Vector(const Vector& other);
Vector.cpp:
Vector::Vector(const Vector& other)
:x(other.x), y(other.y), z(other.z), homogenous(other.homogenous) {
}