为什么我在尝试编译时会出现这个编译错误
Why am i getting this compile error when i try to compile?
我是c++编程的新手,我被分配了一个练习,我得到了一个编译错误
我希望有人能帮我解决这个错误,或者让我了解为什么会发生这种错误下面的代码/*练习21中级:声明一个名为temperatures的七行两列int数组。程序应提示用户输入七天内的最高和最低温度。将最高温度存储在阵列的第一列中。将最低温度储存在第二列中。程序应显示平均高温和平均低温。用小数点后一位显示平均温度。*/
#include <iostream>
#include <iomanip>
using namespace std;
//function prototype
void calcAverage(double temperatures[7][2]);
main()
{
double temperatures[7][2] = {0};
float high = 0.0;
float low = 0.0;
double high_average = 0.0;
double low_average = 0.0;
cout << "Please enter the high then low for the last 7 days " <<endl;
for(int x = 0; x < 6; x += 1)
{
cout << "Please enter the High for day: "<< x+1<<": ";
cin >> high;
temperatures[0][x] = high;
}
for(int x = 0; x < 6; x += 1)
{
cout << "Please enter the Low for day: "<< x+1<<": ";
cin >> low;
temperatures[1][x] = high;
}
//Error is here
calcAverage(high_average, low_average);
// end error
system("pause");
}
void calcAverage(double temperatures[6][1],double &high_average, double &low_average)
{
float accumulator = 0.0;
//for hot average
for(int x = 0; x < 6; x += 1)
{
accumulator += temperatures[0][x];
}
high_average = accumulator;
// for cold average
accumulator = 0.0;
for(int x = 0; x < 6; x += 1)
{
accumulator += temperatures[1][x];
}
low_average = accumulator;
}
44无法为参数 好的, 但你已经过了两次双打。 现在它需要一个双精度的二维数组和两个引用。 从这三个中选择一个并坚持下去。1' to
void calcAverage(double()[2])'转换double' to
double()[2]'void calcAverage(double temperatures[7][2]);
calcAverage
取一个二重的二维数组。calcAverage(high_average, low_average);
void calcAverage(double temperatures[6][1],double &high_average, double &low_average)
相关文章:
- std::is_base_of表示ctor编译错误
- Qt5:使用QCommandLineParser类时出现奇怪的编译错误
- 如何修复sfml c++代码编译错误
- 使用 MATLAB 编码器生成C++代码:编译错误"undefined reference to `rgb2gray_tbb_real64'"
- 使用外部SDK工具链文件在VisualStudio上生成项目编译错误
- vscode下的Arduino代码出现意外编译错误
- 第三方 API 中的编译错误 - Visual Studio
- std::cout输出int时出现编译错误
- 奇怪的代码抛出编译错误模板< J,int aSize=10> C2143:语法错误:在"<"之前缺少";"
- 提升图广度优先搜索前置编译错误
- C++ 中的编译错误:未定义对"主"的引用 collect2:错误:ld 返回 1 个退出状态
- 使用带有 ref 参数的成员函数创建线程时出现编译错误
- 我在C++中遇到了这个奇怪的编译错误
- 在C++中使用 Catch 测试框架编译错误"error: expected ';' at end of declaration list"
- 使用 std::enable_if 限制派生类的模板参数时出现编译错误
- 现代OpenGL和GLEW Libraray的编译错误
- C++ 编译错误:意外的类型名称"字符串":预期的表达式
- C ++程序编译错误,找不到/访问文件
- 使用直接大括号初始化时,C++ 编译错误"声明末尾的预期";"
- 为什么传递非静态成员函数会导致编译错误?