Good day everyone, I've realized hierarchy of classes: Point -> LineSegment.
It's necessary to realize the following methods of the class: moving, stretching, rotating, turning, change on an axis. I'm trying to realize moving at a some distance on this code. What should I search for in my code that it works?
[C++ Error] ClassMethods.cpp(37): E2094 'operator+' not implemented in type 'Point' for arguments of type 'int'
[C++ Error] ClassMethods.cpp(38): E2094 'operator+' not implemented in type 'Point' for arguments of type 'int'
#include <iostream.h>
#include <stdlib.h>
#include <cmath>
#include <conio.h>
// Classes
class Point
{
private:
// Members
double x;
double y;
public:
// Constructor
Point (double _x, double _y) : x(_x), y(_y) {}
};
class LineSegment
{
friend Point operator+ (const Point &, const Point &);
private:
// Members
Point p1; // Bounds of the line segment
Point p2; // Bounds of the line segment
public:
// Constructor
LineSegment (Point &_p1, Point &_p2) // Create a line from 2 points;
: p1(_p1), p2(_p2)
{ }
bool moving(LineSegment &ls) {
int dist;
ls.p1 = ls.p1 + dist;
ls.p2 = ls.p2 + dist;
returntrue;
}
};
int main()
{
Point A(1, 4), B(2, 3);
LineSegment t1(A,B);
cout << "Class hierarchy: Point -> Segment";
return 0;
}