Point Length is a function that computes the distance between two points in a Euclidean plane. It takes two Point objects as input and returns the distance as a double value.
Here is an example of using the Point Length function in C++:
```C++
#include
#include
using namespace std;
class Point {
private:
double x;
double y;
public:
Point(double x = 0, double y = 0) {
this->x = x;
this->y = y;
}
double getX() {
return x;
}
double getY() {
return y;
}
};
double pointLength(Point p1, Point p2) {
double xDiff = p2.getX() - p1.getX();
double yDiff = p2.getY() - p1.getY();
return sqrt(xDiff*xDiff + yDiff*yDiff);
}
int main() {
Point p1(2, 3);
Point p2(7, 8);
double distance = pointLength(p1, p2);
cout << "Distance between p1 and p2 is: " << distance << endl;
return 0;
}
```
In this example, we define a Point class with two private attributes representing the x and y coorinates of the point. We then define a pointLength function that takes two Point objects as input and returns the distance between these two points using the Pythagorean theorem.
The example creates two Point objects p1 and p2, computes the distance between these two points using the pointLength function, and prints the result to the console.
The Point Length function is a part of the standard C++ math library.
C++ (Cpp) Point::Length - 29 examples found. These are the top rated real world C++ (Cpp) examples of Point::Length from package AlgoSolution extracted from open source projects. You can rate examples to help us improve the quality of examples.