I get an error when I try to create an array from the variables I declared.
int row = 8;
int col= 8;
int [row][col];
Why do I get this error:
expression must have a constant value.
arraysc
I get an error when I try to create an array from the variables I declared.
int row = 8;
int col= 8;
int [row][col];
Why do I get this error:
expression must have a constant value.
Best Answer
When creating an array like that, its size must be constant. If you want a dynamically sized array, you need to allocate memory for it on the heap and you'll also need to free it with
delete
when you're done:If you want a fixed size, then they must be declared const:
Also,
doesn't even provide a variable name.