#include < iostream>
#include
using namespace std;
class Shape{
public:
virtual double calArea()=0;
};
class Circle:public Shape
{
private:
double r;//半径
public:
Circle()
{
}
Circle(double r1)
{
r=r1;
}
void setR(double r1)
{
r=r1;
}
double calArea(){
return 3.1415926 * r * r;
}
};
class Rectangle:public Shape{
private:
double width;
double length;
public:
Rectangle()
{
}
Rectangle(double w,double l)
{
width = w;
length = l;
}
double calArea()
{
return width*length;
}
};
class Triangle:public Shape{
private:
double sideA;
double sideB;
double sideC;
public:
Triangle()
{
}
Triangle(double a,double b,double c)
{
sideA = a;
sideB = b;
sideC = c;
}
double calArea()
{
double sum = (sideA+sideB+sideC)/2;
return (sqrt(sum*(sum-sideA)*(sum-sideB)*(sum-sideC)));
}
};
int main()
{
double sum1 = 0;
Shape* s[3]={new Circle(3),new Triangle(3,4,5),new Circle(10)};
for(int i;i<3;i++)
{
sum1 +=s[i]->calArea();
}
cout<<“多种图形的面积和为:”<
}



