0
constant array(not dynamic) length in c++ and c
why array length in c++ should be compile time constant while in c can be runtime?
1 Antwort
+ 3
If you really want to get into it, you will probably want to read some discussions, e.g.
https://stackoverflow.com/questions/1887097/why-arent-variable-length-arrays-part-of-the-c-standard
https://www.sololearn.com/Discuss/2427787/why-does-core-c-not-support-vla
https://www.quora.com/Why-does-C-not-support-a-variable-length-array-and-restrict-it-as-supported-in-C
The gist is that even in C, VLAs haven't really been a prominent feature, to the point where it has become an optional feature with C11. Furthermore, there are implications on the type system that somewhat go against C++ providing more and more compile-time support, and std::vector<> is at least a suitable alternative. In the end, I think there was simply never a widely enough accepted proposition that could have made it into the standard.