A class with no data members

Develop a class with no data members and having following functions
Area() of circle
Area() of rectangle
Area() triangle by heron's formula use this function in main program by creating objects of class.
Could you remind of heron's formula?

I think that the class should contain three overloaded functions Area which accepts correspondingly 1, 2 and 3 arguments.

Only I do not understand why is required to create objects of the class because these functions can be declared as static?
Perimeter = A + B + C
S = Perimeter/2
Area = sqrt(S(S − A)(S − B)(S − C))
1
2
3
4
5
6
struct ShapeArea
{
   static double Area( double ); // for circles
   static double Area( double, double ); // for rectangles
   static double Area( double, double, double ); // for triangles
};


And their definitions as for example of that with three parameters

1
2
3
4
5
double Area( double a, double b, double c )
{
   double s = ( a + b + c ) / 2;
   return ( std::sqrt( s * ( s − a) * ( s − b ) * ( s − c) ) );
}

Last edited on
Is this supposed to be a function object whose class is called Area?
In the original post there is written about functions Area.
Topic archived. No new replies allowed.