个人答案:
#include#include #define PI 3.1415926 using namespace std; class Circle { public: Circle(double,double);//声明构造函数 double Volume(); double Area(); friend void display( Circle&);//声明display函数 private: double radius; double height; }; Circle::Circle(double r,double h) { radius = r; height = h; } double Circle::Volume() { return PI * radius * radius * height; } double Circle::Area() { return 2 * PI * radius * radius + 2* PI* radius * height; } void display( Circle&c1) { cout << "圆柱的表面积: " < 结果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)