Hi I want to initialize a size 9 vector whose elements are vectors of the size, say 5. I want to initialize all the elements to the zero vector.
Is this way correct?
vector<double> z(5,0);
vector< vector<double> > diff(9, z);
OR is there a shorter way to do this?
You could potentially do this in a single line:
You might also want to consider using boost::multi_array for more efficient storage and access (it avoids double pointer indirection).