title: build a shape class Square
body: <p>I have an assignment which I'm finding very difficult. Any help would be appreciated.</p>
  
  <p>Build the hierarchy by creating the Shape classes Circle, Square, and Triangle. For these derived classes, create default constructors and constructors whose arguments can initialize the shapes appropriately using the correct number of Point objects (i.e., Circle requires a Point center and a radius; Square requires four Point vertices, while Triangle requires three Point vertices).</p>
  
  <p>In main(), create one instance each of the following: a Circle with a radius of 23, a Square with sides 25, and a Triangle with sides 10, 20, 30. Define all of them so that the origin (0,0) is somewhere within each object. Display the information from each object.</p>
  
  <p>When I enter under main() Square s(25, Point(0,0));</p>
  
  <pre><code>class Square : public Shape
  {
    double sides;
    Point cp;
  
    public:
    Square() : sides(0) {}
    Square(double side, const Point &amp;center) : sides(side), cp(center){}
  
    void bbox()
    {
       Point bottomright = cp + Point(sides/2, -sides/2);
       Point topleft = cp + Point(-sides/2, sides/2);
       Point topright = cp + Point(sides/2, sides/2);
       Point bottomleft = cp + Point(-sides/2, -sides/2);
  
       std::cout &lt;&lt; "Square::bounding " &lt;&lt; bottomright  &lt;&lt; topleft &lt;&lt; topright &lt;&lt; bottomleft;
    }
  
    double area() {std::cout &lt;&lt; "Square::area "; return (sides * sides);}
    double circumference() {std::cout &lt;&lt; "Square::perimeter "; return sides + sides + sides + sides;}
  
  };
  </code></pre>
  
  <p>The class prints out</p>
  
  <pre><code>Square::area 625
  Square::perimeter 100
  Square::bounding (12.5,-12.5)(-12.5,12.5)(12.5,12.5)(-12.5,-12.5)
  </code></pre>
  
  <p>I'm wondering does this look right based on what the assignment is asking?</p>