C언어 원의 넓이
너에게제공
442 0 0
#include<iostream>
#include<string>
using namespace std;
class Circle
{
private:
double r, area;
public:
Circle(){r=2;}
Circle(double n){r=n;}
void calcArea(){area=3.14*r*r;}
void print();
};
void Circle::print()
{
cout<<"반지름 : "<<r<<endl;
cout<<"원의 넓이 : "<<area<<endl;
}
void main()
{
int n;
Circle cr;
cr.calcArea();
cr.print();
cin>>n;
Circle cr1(n);
cr1.calcArea();
cr1.print();
}