Init 2D Vectors

How can I initialize a 2D vector at the place where its declared.

An single dimension vector is done as shown below:-
std::vector<double> my_1Dvector(10,0.0); //10 double elements with value 0.0

2D Vector:-
std::vector< std::vector<double> > my_2Dvector(10,3,0.0); //is it correct for a 10*3 vector?
You need to call the 1D vector constructor:
std::vector< std::vector<double> > my_2Dvector ( 10, std::vector<double> ( 3, 0 ) );
Means: vector of 10 vectors containing 3 doubles initialized with 0
thx a ton!
Topic archived. No new replies allowed.