Hi, I have a problem with my line class, in that I am stuck trying to get the code to work. My logic is wrong I'm sure of it. But not sure how to fix it. I need to match it with main below. Can anyone tell me where I've gone wrong and show me the correct way to fix it in my codes? Thank you.
class Polygon : public Shape
{
public:
int getArea() {
return (width * height);
}
};
class Line : public Polygon
{
public:
Point() { }; //Default Constructor
Point(int px, int py) { //Constructor
x = px;
y = py;
}
void draw();
};
void Line::draw() {
cout << "Line" << "drawing" << endl;
}
int main()
{
Line l1; //Output: Line construction
std::cout << l1; //Output: Line (0,0) (0,0)
l1.Draw(); //Output: Line drawing
Line l2(Point(),
Point(100,100)); //Output: Line construction
std::cout << l2; //Output: Line (0,0) (100,100)
l1 = l2;
std::cout << l1; //Output: Line (0,0) (100,100)
}
And what have you been 'given', and what have you changed to get into the state you're in?
> as this is a school assignment, I can't modify or change what's been given to me.
There is nothing stopping you creating a parallel file containing whatever code you like that helps you understand the problem.