tags:

views:

188

answers:

3

Possible Duplicate:
Variable length arrays in C++?

I am just curious, is there any particular reason why C++ does not allow variable length arrays?

+2  A: 

What about std::vector?

edit: sorry I missundertood your question.

doc
I'm not complaining, I'm asking why.
Alexander Rafferty
+4  A: 

Two reasons:

  1. C++ is based on C89 (the C standard as published in 1989). VLAs were only introduced in C99.
  2. C++ has std::vector<> and a whole bunch of other containers, which is why I believe that C++ will never bother with VLAs. It already had them when VLAs were invented for C.
sbi
A: 

The STL includes a Vector class to use. Technically, you could use an array whose index variable is a pointer, leading to a "variable length" array.

Madison S
I understand your second point to refer to dynamic arrays. But C has had these, too, from the very beginning.
sbi