Jun 30, 2013 at 12:49pm UTC
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.
Jun 30, 2013 at 1:12pm UTC
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?
Jul 1, 2013 at 1:13pm UTC
Perimeter = A + B + C
S = Perimeter/2
Area = sqrt(S(S − A)(S − B)(S − C))
Jul 1, 2013 at 8:32pm UTC
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
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
Jul 1, 2013 at 8:38pm UTC
Jul 1, 2013 at 11:15pm UTC
Is this supposed to be a function object whose class is called Area?
Jul 1, 2013 at 11:18pm UTC
In the original post there is written about functions Area.