求教:友元函数无法访问类的私有成员。帮我改一下
#include<iostream>using namespace std;
class Round
{
float radius;
public:
Round(float radiusn)
{
radius=radiusn;
}
~Round(){}
friend float perimeter();
friend float area();
};
float perimeter()
{
return 2*3.14*radius;
}
float area()
{
return 3.14*radius*radius;
}
void main()
{
Round R1(5);
cout<<"周长为:"<<perimeter()<<endl;
cout<<"面积为:"<<area()<<endl;
}