作者vincent79715 (轩~)
看板NTUBIME101HW
标题[C++] 考古题 95年-9(class)
时间Thu Jan 15 14:21:51 2009
#define PI 3.1415926
#include <iostream>
using namespace std ;
class Sphere
{
public:
Sphere();
void CalculateVolume() ;
void CalculateSurfaceArea() ;
void PrintSphere() ;
private:
double radius ;
double volume ;
double s_area ;
};
Sphere::Sphere()
{
cin>>radius;
}
void Sphere::CalculateSurfaceArea()
{
s_area=4.0*PI*radius*radius;
}
void Sphere::CalculateVolume()
{
volume = 4.0 / 3.0 * PI*radius*radius*radius;
}
void Sphere::PrintSphere()
{
cout << "表面积=" << s_area << endl ;
cout << "体积=" << volume << endl ;
}
-----------------------------------------------
解答写的好像没办法用?
大家参考一下吧
※ 编辑: vincent79715 来自: 140.112.241.88 (01/15 14:23)
1F:→ sb0917:喔喔!!大感谢!! 01/15 15:06