I want to declare an array of vectors of a certain length. To declare an array of vectors, I write this, for instance:
std::vector<double> myarray[17][38][42];
This creates a 3-dimensional 17x38x24 array, where each element is of type std::vector<double>.
I also know that to specify the size of a std::vector I may write, for instance:
std::vector<double> myvector(14);
This creates a std::vector with space allocated for 14 elements.
I run into a problem when I try to combine these two procedures. For example, writing:
std::vector<double> myarray[17][38][42](14);
I receive this error:
error: array must be initialized with a brace-enclosed initializer [-fpermissive]
std::vector<double> myarray[17][38]42;
When I try to initialize it this way:
std::vector<double> myotherarray(14)[17][38][42];
I receive this error:
error: expected ‘,’ or ‘;’ before ‘[’ token
std::vector<double> myotherarray(14)[17][38][42];
What is the proper way to declare every element of the array to be a std::vector of a certain size?