急!! 请教!!!
[size=4][size=5] 本人刚接触出C++,遇到一个小 问题,请大侠帮助。不胜感激!!以下是我编的一个简单的程序:
#include<iostream>
const PI = 3.1415;
using namespace std;
class Simple_circle
{
public:
Simple_circle();
Simple_circle(double radius) { itsRadius = radius; }
~Simple_circle() {}
double get_radius() const { return itsRadius; }
void set_radius(double r) { itsRadius = r; }
double get_area(const double& );
private:
double itsRadius;
}
Simple_circle::Simple_circle():
itsRadius(5)
{
}
double Simple_circle::get_area(const double& radius)
{
return PI*radius*radius;
}
int main()
{
Simple_circle c1;
cout << c1.get_radius() << endl;
set_radius(5);
cout << "The area is" << c1.get_area(c1.get_radius()) <<endl;
return 0;
}
但是不能通过编译!!
给出三个error:
1.'Simple_circle::Simple_circle' : constructors not allowed a return type
2.'Simple_circle::Simple_circle' : error in function definition or declaration; function not called
3.'set_radius' : undeclared identifier
敬请各位高手指教,先谢谢了!!![/size][/size]