void displayCost();
double computeArea();
double roundCost();
int main()
{
return 0;
}
void displayCost(string name, int size)
{
double area = computeArea(size);
cout << "Since a " << size << "-inch pizza covers" << area << "square inches, "
<< name << ", then a 12 cents per square inch, the cost will be" << 12*area
<< " - which rounds to" << roundCost();
}
double computeArea(int size)
{
double radius = size/2;
double area = pi*radius*radius;
return area;
}
double roundCost(double price)
{
double roundedCost = ceil(price*100)/100;
return roundedCost;
}
它发生在double area = computeArea(size);
的行上。我不明白为什么它说明我没有通过论证。
答案 0 :(得分:5)
double computeArea();
double area = computeArea(size);
double computeArea(int size) {
One of these things is not like the others, ..
您需要修复原型(第一个)以匹配实际功能:
double computeArea(int);
当然,同样适用于其他原型。
答案 1 :(得分:0)
你搞乱你的前瞻声明,他们还必须反映你的功能参数的类型。
void displayCost(string, int);
double computeArea(int);
double roundCost(double);
答案 2 :(得分:0)
C ++与C的不同之处在于函数的前向声明必须指定参数的数量和类型。而在C
double computeArea();
表示有一些名为computeArea
的函数返回double
,在C ++中它与
double computeArea(void);
也就是说,它指定computeArea
不带参数。
据推测,不同之处在于C ++允许函数重载,而C则不允许。
答案 3 :(得分:0)
你已经声明computeArea在原型中获取完全零参数(在main之上)。事实上,你已经将它定义为在下面加倍,这就是重点。在main中,你用一个参数调用它,根据原型,它是错误的。