Does C++ support Variable Length Arrays


C++ does not support variable length arrays. The C++11 standard mentions array size as a constant-expression.

So if we write a program in C++ like:

void displayArray(int n) {
   int arr[n];
   // ......
}
int main() {
   displayArray(7);
}
It will not work.

Updated on: 30-Jul-2019

163 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements