要写一个程序解决计算游泳池栅栏和过道造价的问题,要求是要将造价的计算放到私有里面。
#include"iostream"
#include"string"
using namespace std;
const int AISLE_PRICE=20;
const int FENCE_PAICE=35;
const float PI=3.14;
class circle
{
private:
float a;
float b;
a=AISLE_PRICE*PI*((r+3)^2-(r)^2);
b=FENCE_PAICE*2*PI*r;
public:
void get_r(float r)
{
cout<<"游泳池半径为"<<r<<endl;
}
void price()
{
float c;
float d;
c=a;
d=b;
cout<<"过道的造价为:"<<c<<endl;
cout<<"栅栏的造价为:"<<d<<endl;
}
} ;
int main()
{
int r;
cin>>r;
circle c;
c.get_r(r);
c.price();
return 0;
}
他一直跳出“a" does not name a type;"b" does not name a type