Help please

Here I think I did something wrong with the class line and the operator and I cannot write the main function


here is my code


#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
I need dome help with this operator


point :: double operator-(const point&start , const point&end );
{

point z;
z.x=(start.x-end.x)*(start.x-end.x);
z.y=(start.y-end.y)*(start.y-end.y);
z= sqrt(z.x+z.y)
return z;
}
Last edited on
point start;
point end;
void setstart(double x);
void setend(double y);

^^^ you have 2 points. Ok. now you want to set a point. you give it one coordinate. how is that going to work? It looks like the 2 setters need to both have an x and a y ....
Last edited on
like that
void setstart(double x,double y);
void setend(double x, double y);
I would think so, and then you set BOTH pieces of data in the body ... right?
and then later, I did not look any deeper, you need to make sure that each piece built of lines has multiple lines each with 2 points... I think you did this, but again, I stopped at the line, as it was what you asked.

I would consider making an array at some point, arrays of lines, maybe? What if you moved to 3-d and had to draw a few 20 sided dice objects? That is a lot of stuff to handle via x1 y1 x2 y2... x60 y60... (that would have actually 20 faces each a triangle of 3 lines, 60 points..)
Last edited on
Can you see how I wrote the operator and give my some suggestions of what I should do with the main function
give us your updated code.
and, what main is supposed to do.
don't edit the post, insert your updated code in a new reply.

1
2
point :: double operator-(const point&start , const point&end );
{
there are so many errors there, some are of syntax some are conceptual

I don't understand what's the problem with operators that creates so much confusion
try this, create a function that does what you want, chose a meaningful name, decide if it should be a member function or a free function and decide the number of parameters.

show the call of that function and I will show you how to make it an operator if that makes sense.
Topic archived. No new replies allowed.