本文介绍了无效的类型' double [100] [double]'用于数组下标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
#define MAX 100
double velocity[MAX];
for (itr = 0; itr < velocity[0]; itr = itr + 1)
{
velocity[itr] = velocity[0] - (1*itr);
distance[itr] = rk4_solve(itr, velocity);
cout << setw(5) << itr << setw(9) << velocity[itr] << setprecision(4) << setw(10) << distance[itr] << endl;
}
我正在尝试将值输入到数组中,但是由于某种原因,我收到了错误消息:for循环中3行的数组下标无效类型'double [100] [double]'.
I am trying to input values into the array but for some reason I get the error: i Invalid types 'double [100][double]' for array subscript for the 3 lines inside the for loop.
推荐答案
itr
必须是 int
(或其他整数类型)
itr
must be an int
(or other integer type)
请注意,您在for循环中将 itr
与 velocity [0]
进行比较( itr< velocity [0];
).您可能是说 itr<MAX
,我希望您在某处定义了变量 itr
Be aware that you are comparing itr
with velocity[0]
in the for cycle (itr < velocity[0];
). You probably meant itr < MAX
, and I hope somewhere you defined the variable itr
这篇关于无效的类型&#39; double [100] [double]&#39;用于数组下标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!