I know this question has already been ask, but I couldn't figure it out. I have two classes Point and Line, and 2 Points are members of Line. However in the Line constructor I get "no default constructor exists for the class" error. How can I fix this problem?
#include <cstdlib>
#include <cmath>
#include "PointClass.h"
using namespace std;
class Line {
public:
Line(const Point& p1, const Point& p2) {
this->point1 = p1;
this->point2 = p2;
}
Point point1;
Point point2;
static double Distance(Point p1, Point p2, Point p3) {
double distance = (abs((p1.y - p2.y) * p3.x - (p2.x - p1.x) * p3.y + p2.x * p1.y - p2.x * p1.x) / (sqrt(pow((p2.y - p1.y), 2.0) + pow((p2.x - p1.x), 2.0))));
return distance;
}
};
class Point {
public:
Point(double a, double b) {
this->setCoord(a, b);
}
double x;
double y;
void setCoord(double a, double b)
{
this->x = a;
this->y = b;
}
};