简体   繁体   中英

Initialize array of vectors

I am trying to initialize an array of vectors. How can I do that ?

The following code is wrong:

vector<int> A[] = vector<int>()[10];
std::array<std::vector<int>, 10>

这将为您提供一个包含 10 个向量的数组。

Try just

vector<int> A[10];

It will default-initialize all ten vector objects.

vector<int>* A = new vector<int>[10];

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