计算圆周长,面积的程序,我的结果是错的 请各位亲们帮我看下可好?
#include <iostream.h>class Box
{public:
double girth();
double area();
private:
int r;
};
double Box::girth()
{double girth=0;
girth=2*3.14*r;
return girth;
}
double Box::area()
{double area=0;
area=3.14*r*r;
return area;
}
int main()
{int r;
double girth,area;
Box box1;
cin>>r;
cout<<"girth="<<box1.girth()<<endl;
cout<<"area="<<box1.area()<<endl;
return 0;
} 为什么结果不对啊 亲们帮我看下,顺便解释下为什么 好么?