[英]C++ problems passing array to function
I have this code: 我有以下代码:
#include <iostream>
using namespace std;
int recursivefunction(int NbProducts, int NbPlates, int prevlevel, int currentlevel, int thearray[] ) {
currentlevel = (prevlevel + 1);
if(prevlevel = 0) { currentlevel = 1; } //only ensures that the FIRST run has no issues with negatives
while(thearray[currentlevel] < (NbProducts - NbPlates + 1)) {
if(currentlevel = NbPlates) {
cout << thearray[currentlevel] << endl; //debug, do something to test full program
}
else recursivefunction(NbProducts, NbPlates, prevlevel, currentlevel, thearray[] );
}
}
int main() {
int NbProducts = 10, NbPlates = 3, prevlevel = 0, currentlevel = 0;
int thearray[100];
recursivefunction (NbProducts, NbPlates, prevlevel, currentlevel, thearray[]);
}
and it keeps giving me "expected a value before the ']' in "thearray". Ignore the rest of the program, it doesn't do anything right now. If I give a value inside of those brackets it gives me a multitude of other errors. Any ideas? 并且一直给我“ thearray中的']'之前的期望值。忽略程序的其余部分,它现在什么也不做。如果我在那些括号内给出一个值,则会给我很多其他错误,有什么想法吗?
当您调用该函数时,它应该不带数组本身传递[]
recursivefunction (NbProducts, NbPlates, prevlevel, currentlevel, thearray);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.