How do I declare a 2d array in C++ using new?

If your row length is a compile time constant, C++11 allows See this answer. Compilers like gcc that allow variable-length arrays as an extension to C++ can use new as shown here to get fully runtime-variable array dimension functionality like C99 allows, but portable ISO C++ is limited to only the first dimension being variable. Another efficient option is … Read more

How do I declare a 2d array in C++ using new?

If your row length is a compile time constant, C++11 allows See this answer. Compilers like gcc that allow variable-length arrays as an extension to C++ can use new as shown here to get fully runtime-variable array dimension functionality like C99 allows, but portable ISO C++ is limited to only the first dimension being variable. Another efficient option is … Read more