C++ does not have such unrestricted run-time sized arrays. C++11 introduced a feature remotely similar to C VLAs, but it is significantly more limited. You are not allowed to have VLA of VLAs in C++, meaning that the second, third and further dimensions of any multi-dimensional array in C++ must be constant expressions.
Apparently, this is the requirement you violated. Your N
is not a constant expression.
In any case, the title of your question talks about initialization, while in reality the problem you experienced is not related to initialization at all. The initialization syntax you used - ()
- is not new for C++11, it existed in C++ since the very first language standard.
The only C++11 feature in your code is the above usage of auto
. But it has nothing to do with initialization or arrays specifically.