简体   繁体   中英

Difference between declaring 2d vectors by two ways

What is difference between these two ways of declaring 2d vectors:

vector<vector<int>> b(n+n-1);

and

vector<vector<int>> b(n+n-1, vector<int>(n+n-1));

vector<vector<int>> b(n+n-1);

Allocate a vector b with n+n-1 elements and initialize the elements with default value (a vector with zero elements) .

vector<vector<int>> b(n+n-1, vector<int>(n+n-1));

Allocate a vector b with n+n-1 elements and initialize the elements with the specified value (a vector with n+n-1 elemements) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM