Why am I able to use a locally declared const int as the size of an array declaration but am not allowed to do the same with a const int passed as
Array size should be known at compile time.
const int with local variables may do not work neither if the value is not known at compile time as:
void f2(){
const int dim = bar();
int nums[dim]; // error
}
In Both case, const int tells that the value doesn't change, not that is it known at compile time.