C++ – Does C++ Support Variable Length Arrays?

c++c++11variable-length-array

No, wait, bear with me…

VLAs were always a GCC extension, but they were adopted by C99:

[C99: 6.7.5.2/4]: If the size is not present, the array type is an
incomplete type. If the size is * instead of being an expression, the
array type is a variable length array type of unspecified size, which
can only be used in declarations with function prototype scope; such
arrays are nonetheless complete types. If the size is an integer
constant expression and the element type has a known constant size,

the array type is not a variable length array type; otherwise, the
array type is a variable length array type.

C99 is also known as ISO/IEC 9899:1999.

Now:

[C++11: 1.1/2]: C++ is a general purpose programming language based
on the C programming language as specified in ISO/IEC 9899:1999
(hereinafter referred to as the C standard). In addition to the
facilities provided by C, C++ provides
additional data types, classes,
templates, exceptions, namespaces, operator overloading, function name
overloading, references, free store management operators, and
additional library facilities.

So shouldn't C++11 have VLAs too?

Best Answer

That leeway wording doesn't mean that any and everything in C99 is in C++11. What you quoted is just introductory text.