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.