In C++ books, array bound must be constant expression, but why the following code works?

前端 未结 2 1936
感情败类
感情败类 2020-11-22 13:13
#include 
using namespace std;

int main(){
    int n=10;
    int a[n];

    for (int i=0; i

        
2条回答
  •  天涯浪人
    2020-11-22 13:53

    That is C99 feature that allows VLA (variable length array).

    Compile it with g++ -pedantic, I'm sure that wouldn't compile.

提交回复
热议问题