#include
using namespace std;
class Triangle
{
public:
Triangle();
Triangle(double Bottom,double Height);
double TriangleArea();
protected:
double triangleBottom,triangleHeight;
};
Triangle::Triangle()
{
}
Triangle::Triangle(double Bottom, double Height){
triangleBottom=Bottom;//三角形底边
triangleHeight=Height;//三角形高
}
double Triangle::TriangleArea(){
double area= 0.5*triangleBottom*triangleHeight;
return area;
}
class Triangularpyramid:public Triangle
{
public:
Triangularpyramid();
Triangularpyramid(double trianglebottom, double triangleheight,double height);
double Volume();
protected:
double Height;
};
Triangularpyramid::Triangularpyramid()
{
}
Triangularpyramid::Triangularpyramid(double trianglebottom, double triangleheight, double height){
Triangle(trianglebottom,triangleheight);
Height=height;
}
double Triangularpyramid::Volume(){
double volume= 0.33*triangleBottom*triangleHeight*Height*0.5;
cout<<triangleBottom;
cout<<triangleHeight;
return volume;
}
int main(){
Triangularpyramid trianglepyramid01(5,6,7.4);
cout<<trianglepyramid01.Volume();
return 0;
}