#include<iostream>.
#include<math.h>
using namespace std;
class Circle
{
public:
double Transfer(double newr);
double area();
private:
double r;
};
double Circle::Transfer(double newr)
{
r=newr;
}
inline double Circle::area()
{
cout<<r*r*3.14<<endl;
}
int main()
{
Circle newcircle;
double a;
while(cin>>a)
{
newcircle.Transfer(a);
newcircle.area();
}
return 0;
}
在用类时 记得类和结构体一样的地方就是class Circle不用加“()”还有在后面要加“;”
时间: 2024-10-16 08:29:54