Trouble with class composition

I'm trying to write a basic program that uses a point class and a vector class to perform basic vector algebra(add subtract, dot product and cross product). I'm having some difficulty writing the .cpp file for the vector class. I can't figure out how to create some of the functions I need to perform on vectors. I'm trying to write the dot product function as double Vector::dot(Vector V2); which I want to implement in the main function such as v1.dot(v2) to calculate the dot product of vectors v1 and v2. I attempted to write it as dot=V.getX()+V2.getX+V.getY()+V2.getY()+V.getZ()+V2.getZ(); this should return a double type value, but even though I have V and V2 specified as points in the Vector.h file, it will not recognize the get methods for V2. I do have a point.h class as well with the get and set methods. I guess I'm confused as to how to write the methods that I need using the vector class. Any help would be greatly appreciated.
That seems to be beyond the abilities of a beginner. I would try "General C++ Programming" forum.
You need to show the code. And I would have overloaded the operator* instead of creating a dot() function. And isn't the dot product like this: v.getX() * v2.getX() + .... ? You show all sums in your explanation.

1
2
3
4
double Vector::operator*(const Vector &op2)
{
    return getX() * op2.getX() + getY() * op2.getY() + getZ() * op2.getZ());
}
Thanks. You're right it should have been multiplication rather than addition. I was confused as to how to overload operators that's why I was trying to do it the longer way. Thanks for your help though.
Topic archived. No new replies allowed.