Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 5
    I think you are approaching the problem from the wrong direction. Every concrete child of shape should know how to calculate its area based on its member variables. No parameters should be required. Commented Dec 21, 2019 at 19:52
  • The Shape shouldn't know or care if what is derived needs 2, 3, 4, 5, or 100 points to calculate the area. Those items should be known by the derived class, not Shape. On the other hand, your design would be perfect if on purpose, you only wanted derived shapes that took exactly 4 points to define the area. The compiler did its job, and that is to error out because your Triangle violated the restrictions of how to compute the area. Commented Dec 21, 2019 at 19:59