c++ 計算指定半徑圓的面積
阿新 • • 發佈:2018-11-23
#include <iostream> #define PI 3.14 using namespace std; class Circle { float radius; public: void getRadius(); float area(); void showRadius(); }; void Circle :: getRadius() { cout << "Enter Radius ::: "; cin >> radius; } float Circle :: area() {float ar; ar = PI * radius * radius; return ar; } void Circle :: showRadius() { cout << "\n Radius : " << radius; } int main() { Circle c1; c1.getRadius(); c1.showRadius(); float a = c1.area(); cout << "\n Area of Circle : " << a; return0; }