参数太少导致函数错误?(c++)
Too few arguments to function error? (C++)
我不知道为什么这个代码不工作,任何帮助将不胜感激。不管我怎么做,我还是会得到相同的错误。我知道需要传递更多的参数,但我只是不知道我可以添加什么。
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
double getSales();
void findHighest(double sale[]);
int main()
{
double sales;
const int ARRAY_SIZE = 4;
double salesNE, salesSE, salesNW, salesSW;
double highest = 0;
string winner;
string names[ARRAY_SIZE] = {"Northeast", "Southeast", "Northwest", "Southwest"};
double sale[ARRAY_SIZE];
int counter = 0;
cout<<"Input data for the Northeast Division:"<<endl;
sale[0] = getSales();
cout<<"Input data for the Southeast Division:"<<endl;
sale[1] = getSales();
cout<<"Input data for the Northwest Division:"<<endl;
sale[2] = getSales();
cout<<"Input data for the Southwest Division:"<<endl;
sale[3] = getSales();
findHighest();
system("PAUSE");
return 0;
}
double getSales()
{
double sales;
validate:
cout<<"Enter the quaterly sales figures for this division:"<<endl;
cin>>sales;
if (sales < 0)
{
system("CLS");
cout<<"Invalid input: sales figures must be higher than $0.00"<<endl;
goto validate;
}
return sales;
}
void findHighest(double sale[])
{
const int ARRAY_SIZE = 4;
double highest = 0;
int counter = 0;
string winner;
string names[ARRAY_SIZE] = {"Northeast", "Southeast", "Northwest", "Southwest"};
while (counter < ARRAY_SIZE)
{
if (sale[counter] > highest)
{
highest = sale[counter];
winner = names[counter];
}
counter += 1;
}
cout<<"The "<<winner<<" division had the highest grossing sales at $"<<highest<<"." <<endl;
}
findHighest()函数中缺少函数参数
函数减速为void findHighest(double sale[]);
您没有提供参数double sale[]
findHighest(sale)
findHighest()
[ system("PAUSE")语句前一行]你的函数调用:
findHighest();
函数声明:
void findHighest(double sale[]);
看到这些"Too few arguments to function"错误有意义吗?这个错误是不言自明的。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 为什么在运行时没有向我们提供有关分段错误的更多信息?
- 错误:未在此范围内声明'reverse'