Is the size of an array determined at compile time?

后端 未结 3 1904
长情又很酷
长情又很酷 2021-01-19 19:25

When I was reading about the array initialization in this tutorial. I found out this note.

type name [elements];

NOTE: The e

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 20:14

    You may use :

    int array[42];
    

    but not

    int n;
    std::cin >> n;
    int array[n]; // Not standard C++
    

    the later is supported as extension by some compiler as VLA (Variable length array)

提交回复
热议问题