I have the following functions (which were worked in Visual Studio):
Bool Plane: In (vector and point) {return Normal Vector.dotProduct (point - position)
When I compile it using g ++ version 4.1.2, I get the following error:
Plane.cpp: In the Member Function, Virtual Child Plane: Includes: (Vector and): Plane CPP: 36: Error: Vector :: There is no matching vector to call for dot product (vector). H: 1 9: Note: Candidates are: Double Vector :: Dot Product (Vector End)
So you can see, the compiler thinks (point-position) is a vector, but This vector is expected.
What is the best way to fix this?
I've verified that this works:
vector temp = point-position; Return Normal Vector.dotProduct (temp) & lt; -doubleResolution;
But I was hoping for a little cleaner.
I have heard a suggestion that adding a copy constructor can help. So I added a copy constructor to vector (see below), but it does not help
vector H:
vector (Cunt vector and others);
vector. CPP:
Vector :: Vector (Constant Vector and others): X (Other X), y (Other.A.), Z (other.z), Symph (Other.Homogensus) {}
Your problem is that point - status
The result of is a temporary thing, which can not be compelled for a non-conference reference.
If a function does not modify any argument taken by reference, then it should take a const reference. Therefore, your Dot Product Function should be declared as:
Double vector :: dot product (Cantt vector & amp;;);
Comments
Post a Comment