I don\'t really understand why I can\'t have a variable size array on the stack, so something like
foo(int n) {
int a[n];
}
As I underst
Simple answer: because it is not defined in the C++ standard.
Not so simple answer: Because no one propsed something behaving coherently for C++ in that case. From the standards POV there is no stack, it could be implemented totally differently. C99 has VLAs, but they seem to be so complex to implement that gcc only finished the implementation in 4.6. I don't think many people will want to propose something for C++ and see compiler manufacturers struggle with it for many years.