You can use:
int const size = 10; int array[size];
to create an array in C ++. However you cannot use
void temp_arr ( const int array_size ) { int temp_arr[array_size]; }
to create an array if the compiler does not support VLA as an extension. The standard does not support VLA.
The const qualifier in the argument type simply turns the const variable into a function - you cannot change its value. However, the value may not necessarily be determined at compile time.
For example, you can call a function using:
int size; std::cout << "Enter the size of the array: "; std::cin >> size; temp_arr(size);
Since a value cannot be necessarily determined at compile time, it cannot be used to create an array.
source share