#include<iostream>
using namespace std;
class circle{
public:
float area();
circle();
circle(float r);
public:
float radius;
};
circle::circle()
{
radius=1.0;
}
circle::circle(float r)
{
radius=r;
}
float circle::area()
{
return radius*radius*3.14;
}
void main()
{
circle c1;
cout<<"圆1的面积="<<c1.area()<<endl;
circle c2(5);
cout<<"圆2的面积="<<c2.area()<<endl;
}
作业3.22
最新推荐文章于 2022-03-22 20:55:46 发布