#include <iostream>
using namespace std;
class Point
{
public:
Point(double a,double b)
{
x=a;
y=b;
}
protected:
double x;
double y;
};
class Circle:public Point
{
public:
Circle(double a,double b,double r):Point(a,b),r(r) {}
double getarea();
protected:
double r;
double area;
};
double Circle::getarea()
{
area=3.141*r*r;
return area;
}
class Cylinder:public Circle
{
public:
Cylinder(double a,double b,double r,double h):Circle(a,b,r),h(h) {}
double getvolume();
friend ostream & operator<<(ostream &,const Cylinder &);
protected:
double h;
double volume;
};
double Cylinder::getvolume()
{
getarea();
volume=area*h;
return volume;
}
ostream & operator<<(ostream &out,const Cylinder &C)
{
cout<<"该点的坐标为:"<<"("<<C.x<<","<<C.y<<")"<<endl;
cout<<"以该点为圆心,半径为"<<C.r<<"的圆的面积为:"<<C.area<<endl;
cout<<"以该圆为底,高为"<<C.h<<"的圆柱体体积为:"<<C.volume;
return out;
}
int main()
{
Cylinder a(3,4,5,10);
a.getvolume();
cout<<a;
return 0;
}