I am working on a project that has us working with classes and in the project we are using a .cpp .hpp and a main method.cpp. I have it working to store the input from the main file and output them. where I am having trouble is when I incorporate the the distanceTo into the main and I get (no matching function for call to ‘Point::distanceTo(Point&)’ double dist = p1.distanceTo(p2);) Further how to I take the X's and the Y's from p1 and p2 and get the hypotenuse? I figure I would need to take the absolute value of both x and y add them together then use that good old Pythagorean theorem to get the length of the hypotenuse.
What is the function distanceTo supposed to be doing? Is it supposed to be finding the distance between 2 Points? It seems as if you are trying to find the hypotenuse, which doesn't make sense, as the hypotenuse does not exist if there are only 2 Points (i.e. 1 line).
yes I am trying to take input from the main file as 2 sets of points and use them to find the hypotenuse I it should have been using the distance formula in the .cpp file thought I changed it. the end result is the same error though.
I figure I would need to take the absolute value of both x and y add them together then use that good old Pythagorean theorem to get the length of the hypotenuse
I forgot to mention that you don't need to worry about the absolute values because you are squaring the x difference and y difference so whatever they are and whatever the order of p1 and p2, ie p1->p2 or p2->p1 the sum of the squares of ie the differences will always be positive. ie the scalar distance is always positive. ( The direction vector doesn't use absolute values either.)