当数据成员是double类型的时候,为什么会和string类型冲突?
#include <iostream>
#include <string>
using namespace std;
class Cylinder
{
public:
Cylinder()
{
height=0;
radius=0;
PI=3.1415926;
}
void SetPi(double PI)
{
PI=3.1415926;
}
string GetPi()
{
cout<< PI<<",";
}
void SetRadius(double b)
{
radius=b;
}
string GetRadius()
{
cout<< radius<<",";
}
void SetHeight(double a)
{
height=a;
}
string GetHeight()
{
cout <<height;
}
void Volume(double a,double b)
{
double c;
c=(PI*b*b*a);
cout<<c;
}
void Area(double a,double b)
{
double d;
d=(2*PI*b*a);
cout<< d;
}
private:
double height;
double radius;
double PI;
};
int main()
{
Cylinder cy;
double a,b;
cin>>a>>b;
cy.SetHeight(a);
cy.SetRadius(b);
cy.GetPi();
cy.GetHeight();
cout<< ",";
cy.GetRadius();cout<<",";
cy.Volume(a,b);cout<<",";
cy.Area(a,b);
cout<<endl;
return 0;
}
**** 2016/10/30 15:06:39
求解什么地方错了
15:10:56
**** 2016/10/30 15:10:56
大神求解
**** 2016/10/30 15:11:00
在线等
15:15:10
**** 2016/10/30 15:15:10
#include <iostream>
#include <string>
using namespace std;
class Cylinder
{
public:
Cylinder()
{
height=0;
radius=0;
PI=3.1415926;
}
void SetPi(double PI)
{
PI=3.1415926;
}
string GetPi()
{
cout<< PI<<",";
}
void SetRadius(double b)
{
radius=b;
}
string GetRadius()
{
cout<< radius<<",";
}
void SetHeight(double a)
{
height=a;
}
string GetHeight()
{
cout <<height;
}
void Volume(double a,double b)
{
double c;
c=(PI*b*b*a);
cout<<c;
}
void Area(double a,double b)
{
double d;
d=(2*PI*b*a);
cout<< d;
}
private:
double height;
double radius;
double PI;
};
int main()
{
Cylinder cy;
double a,b;
cin>>a>>b;
cy.SetHeight(a);
cy.SetRadius(b);
cy.GetPi();
cy.GetHeight();
cout<< ",";
cy.GetRadius();cout<<",";
cy.Volume(a,b);cout<<",";
cy.Area(a,b);
cout<<endl;
return 0;
}