Hey!
I'm learning C++ and I'm experiencing something a bit strange, to me at least.
My compiler allows this:
int main() {
int i = 5;
int j = 5;
int arr[j];
}
And this:
void arrayFunction(int a[][5]) {
}
int main() {
int arr[5][5];
arrayFunction(arr);
}
But not this:
void arrayFunction(int a[][5]) {
}
int main() {
int i = 5;
int j = 5;
int arr[j];
arrayFunction(arr); //line L
}
Giving this message about line L:
cannot convert `int (*)[((unsigned int)((int)j))]' to `int (*)[5]' for argument `1' to `void arrayFunction(int (*)[5])'
I noticed one compiler (online at a code pasting site) that did not allow the first piece of code, so maybe that's something one should not do. And in that case, how am I supposed to know what array size I'm going to need when I write the code.