我编写了这个程序来计算圆的面积,它一直给我这个错误消息:“未定义对'printHeader()的引用和对'calculateArea(double&)'的未定义引用”
我无法弄清楚这意味着什么!我到处都看过,包括这个网站,但大多数答案都超出了我的想象。
程序:
#include <iostream>
using namespace std;
// Aquire radius value
// Postcondition: print out header and return radius value
double printHeader();
// Precondition: radius has been entered
// Postcondition: calculate and print out area of the circle
void calculateArea(double& radius);
int main()
{
double area=0.0, radius=0.0;
printHeader();
calculateArea(radius);
return 0;
}
double printHeader(double& radius)
{
cout << "Program for calculating the area of a circle" << endl;
cout << "Enter the radius of the circle: ";
cin >> radius;
return radius;
}
void calculateArea(double& radius, double area)
{
double PI=3.14159;
area = (PI*radius*radius);
cout << "The area of the circle is: " << area << endl;
}
我正在使用代码块。非常感谢!