Simplest 2D array, using g++, with one variable dimension?
问题 I would like to make an array like this: double array[variable][constant]; Only the first dimension is variable. Declaring this with a variable as the first dimension gives initialization errors. Is there a simple way to do this with pointers or other basic types? 回答1: Variable length arrays didn't make it in the latest C++ standard. You can use std::vector instead std::vector<std::vector<double> > arr; Or, to fix for example the second dimension (to 10 in this example), you can do std: