![](/img/trans.png)
[英]What is the correct way to create vector of Promises and collect in a vector of futures in c++?
[英]What is the correct way to output a whole vector/array? [C++]
在C ++中輸出整個容器的正確方法是什么(在這種情況下,目標是向量和數組)? 我可能想在其中放置空格,或像這樣對它們進行排序:
1: (first element)
2: (second element)
3: (third element)
等等...?
答案是通過循環遍歷每個元素:
// Array
for (int i = 0; i < size_of_array; ++i) {
std::cout << i << ": " << array[i] << "\n";
}
向量相同,但是替換i < size_of_array;
與i < name_of_vector.size();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.