Question: The following code introduces a variable - length array ( VLA ) on the stack: int size = 0 ; std::cin > > size; int

The following code introduces a variable-length array (VLA) on the stack:
int size =0;
std::cin >> size;
int array[size];
Is this code valid per the C++ standard?
No, since the code will not compile on any modern C++ compiler.
No, the C++ standard states that the compiler must know a stack array's size at compile time.
Yes, variable-length arrays are valid in the C99 standard.
Yes, variable-length stack arrays are valid per the C++98 standard.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!