You have two definitions of Parallelogram::Parallelogram(Point, Point, Point)
; one inside the class and one outside. You can't have multiple definitions of a function.
Assuming add
adds a point to your Polygon
, it seems like you really just want the second definition to be part of the first. You can define that inside your class like so:
struct Parallelogram : public Polygon {
Parallelogram(Point tl, Point tr, Point bl) {
Point br;
int num = tr.y-tl.y;
int denom = tr.x-tl.x;
br.x=denom+bl.x;
br.y=num+bl.y;
add(tl);
add(tr);
add(bl);
add(br);
}
};
Alternatively, you can declare it inside your class and then define it outside:
struct Parallelogram : public Polygon {
Parallelogram(Point tl, Point tr, Point bl);
};
Parallelogram::Parallelogram(Point tl, Point tr, Point bl) {
Point br;
int num = tr.y-tl.y;
int denom = tr.x-tl.x;
br.x=denom+bl.x;
br.y=num+bl.y;
add(tl);
add(tr);
add(bl);
add(br);
}