Q:

multi-dimensioned array initialization using const

This kind of initialization works  
int arr[3][4] = { {1,2,3,4}, {1,2,3,4}, {1,2,3,4} } ;  

but this one here doesn't
const size_t row_size = 3;  
const size_t col_size = 4;  

int arr[row_size][col_size] = { {1,2,3,4},{1,2,3,4},{1,2,3,4}};  

these codes are in c but after changing the file extension to c++ and re-compiling
it works fine. why such a behavior?

A:

That used to be a problem with C and macros were used to solve such problems. But in C++ if you use "const" keyword then the compiler should automatically replace those values during compile time so there shouldn't be any problem with g++. That code runs perfectly fine when compiled with g++. Maybe you are trying to compile it with gcc (I got the same error with gcc which is as expected).

