So my program is supposed to make two points(each with an x and y value that is inputed by the user), find a third point that would make a right triangle and print out the value of the third point. I finished it but in the main when it tries to construct a triangle(with two references to points) the debugger says "no matching function for call to 'Point::Point(). Please tell me if im doing anything wrong. I don't know what to do to fix it.
Code:
struct Point
{
public:
Point(int x,int y);
~Point ();
int getX() const;
int getY() const;
private:
int xCord;
int yCord;
};
struct Triangle
{
public:
Triangle(const Point& p1, const Point& p2);
~Triangle();
Point getFirstPoint() const;
Point getSecondPoint() const;
Point getThirdPoint() const;
private:
Point pointOne;
Point pointTwo;
Point pointThree;
Point findThirdPoint();
};
int main()
{
int xCord;
int yCord;
// user inputs values for point 1
Point one = Point(xCord, yCord);
// user inputs values for point 2
Point two = Point(xCord, yCord);
const Point &pOne = one;
const Point &pTwo = two;
// This next line is the call to a constructor that throws an error
And since there is no default constructor for Point defined, the compiler can't generate that code. You should prefer using an initialization list in constructors as opposed to assignment in the body of the function.