OK fellow coders, I can't work this one out. I'm passing a const value to a function and using that const value to declare the array size inside a function.
here are the errors i get:
.cpp(17) : error C2057: expected constant expression
.cpp(17) : error C2466: cannot allocate an array of constant size 0
.cpp(17) : error C2087: '<Unknown>' : missing subscript
I will be very grateful if someone can help.
Thanks
Kunal.
Code:
void foo( int a[], const int columns );
int main()
{
const int SIZE = 10;
int array[SIZE] = {0};
foo( array, SIZE );
return 0;
}
void foo( int a[], const int columns )
{
const int rows = 10;
int b[rows][columns] = { 0 }; //Line 17
}
here are the errors i get:
.cpp(17) : error C2057: expected constant expression
.cpp(17) : error C2466: cannot allocate an array of constant size 0
.cpp(17) : error C2087: '<Unknown>' : missing subscript
I will be very grateful if someone can help.
Thanks
Kunal.