What is the reason c++ doesn't allow to specify array size at runtime. is it because of pointer usage(like pointer arithmetic, i'm assuming it is for keep elements in contiguous memory locations) or because of some other reason. Can someone please explain me why it is designed that way.
Asked
Active
Viewed 77 times
0
-
1Largely historical: it wasn't in C when C++ was "forked", and C++ had added `std::vector` before C added VLAs. Given the presence of `std::vector` being able to specify an array size at run time would take quite a bit of work, but add little (if anything) in the way of new capability. [Aside: some C++ compilers such as gcc, support it as an extension.] – Jerry Coffin Apr 01 '15 at 15:50
-
@Jerry Thanks Jerry. it makes more sense. sorry i can't up vote your comment yet. but it was really helpful. – HarshaXsoad Apr 07 '15 at 05:48