作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我不知道该怎么办?我得到了与标题中一样的错误:错误:重载函数“findCircumference”的多个实例与参数列表匹配。
我正在为这项任务使用范围和功能。如果我能弄清楚这个错误,我就可以继续从事其他项目。请帮忙。
#include <iostream>
#include <iomanip>
using namespace std;
// This program will demonstrate the scope rules.
// PLACE YOUR NAME HERE
const double PI = 3.14;
const double RATE = 0.25;
void findArea(float, float);
void findCircumference(float, float);
int main()
{
cout << fixed << showpoint << setprecision(2);
float radius = 12;
cout <<" Main function outer block" << endl;
cout <<" LIST THE IDENTIFIERS THAT are active here" << endl << endl;
{
float area;
cout << "Main function first inner block" << endl;
cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;
findArea(radius, area);// Fill in the code to call findArea here
cout << "The radius = " << radius << endl;
cout << "The area = " << area << endl << endl;
}
{
float radius = 10;
float circumference;
cout << "Main function second inner block" << endl;
cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;
findCircumference(radius, circumference);
cout << "The radius = " << radius << endl;
cout << "The circumference = " << circumference << endl << endl;
}
cout << "Main function after all the calls" << endl;
cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;
return 0;
}
// *********************************************************************
// findArea
//
// task: This function finds the area of a circle given its radius
// data in: radius of a circle
// data out: answer (which alters the corresponding actual parameter)
//
// ********************************************************************
void findArea(float rad, float answer)
{
cout << "AREA FUNCTION" << endl << endl;
cout << "LIST THE IDENTIFIERS THAT are active here"<< endl << endl;
answer = (rad*PI)*(rad*PI);
cout << answer <<endl;
// FILL in the code, given that parameter rad contains the radius, that
// will find the areato be stored in answer
}
// ******************************************************************************
// findCircumference
//
// task: This function finds the circumference of a circle given its radius
// data in: radius of a circle
// data out: distance (which alters the corresponding actual parameter)
//
// *****************************************************************************
void findCircumference(float length, float& distance)
{
cout << "CIRCUMFERENCE FUNCTION" << endl << endl;
cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;
distance = (length*2)*PI;
cout << distance << endl;
// FILL in the code, given that parameter length contains the radius,
// that will find the circumference to be stored in distance
}
最佳答案
您的前向声明是针对一个函数,该函数按值接受两个 float
参数
void findCircumference(float, float);
但是您的函数签名略有不同,一个 float
按值取值,第二个作为引用
void findCircumference(float, float&);
// ^
您需要更改它们以匹配,大概是通过更正前向声明。
关于c++ - 错误 : More than one instance of overload function "findCircumference" matches the argument list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20363328/
我不知道该怎么办?我得到了与标题中一样的错误:错误:重载函数“findCircumference”的多个实例与参数列表匹配。 我正在为这项任务使用范围和功能。如果我能弄清楚这个错误,我就可以继续从事其
我是一名优秀的程序员,十分优秀!