Create a class representing a point in 2D space with methods to calculate the distance from another point.
HardProblem Statement
Create a class representing a point in 2D space with methods to calculate the distance from another point.
Sample Input
Point p1(3, 4); Point p2(6, 8);
Sample Output
Distance between points: 5
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
#include <cmath>
#include <iostream>
class Point {
private:
int x, y;
public:
Point(int xCoord, int yCoord);
double distance(Point p);
};
int main() {
// Logic to demonstrate distance calculation
return 0;
}
Input
Point p1(3, 4); Point p2(6, 8);
Expected Output
Distance between points: 5