看板 NTUBIME101HW 關於我們 聯絡資訊
#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)
sb0917:喔喔!!大感謝!! 01/15 15:06