I am relatively new to C ++, and from the very beginning it was drilled into me that you cannot do something like
int x; cin >> x; int array[x];
Instead, you should use dynamic memory. However, I recently discovered that the above will be compiled (although I get an error message saying that this is prohibited by ISO C ++). I know that this is clearly a bad idea if it is not permitted by the standard, but I did not even know before that it was possible.
My question is, why does g ++ allow variable length arrays that are not dynamically allocated if it is prohibited by the standard? Also, if it is possible for the compiler, then why is this not a standard?
c ++ dynamic-arrays
Maulrus
source share