Help with shapes?

Hi!
I'm very stuck on some code and I could use a bit of help.


Square::Square( const float width , const Point origin ) : width( width )
{
_origin = origin;
bounds.left = origin.x - width / 2.0f;
bounds.top = origin.y - width / 2.0f;
bounds.width = width;
bounds.height = width;
}

Last edited on
Please show the complete error including the line numbers [and file names].

The range based for loop on line 131 requries the C++11 standard. Either you have a very old compiler or you need to switch on the C++11 option.
The code compiles fine with C++11. If you can't get a C++11 compiler then change the for loop at line 131.

You say part A is complete but I don't see these:
Overload the [<<] operator to print point values and the + and – operators to add and subtract point coordinates


You still need Shape::display().

Shouldn't class Square let you create a square with sides that aren't horizontal & vertical?

Shouldn't class Triangle let you create a triangle from any 3 points?

To support these enhancements, I'd get rid of _origin in class Shape. I'd represent a square by two points on a diagonal. Represent a circle by a center and radius, and a triangle by 3 points.
Topic archived. No new replies allowed.