C++:vector assign
// vector assign
#include <iostream>
#include <vector>
int main ()
{
std::vector<int> first;
std::vector<int> second;
std::vector<int> third;
first.assign (7,100); // 7 ints with a value of 100
std::vector<int>::iterator it;
it=first.begin()+1;
second.assign (it,first.end()-1); // the 5 central values of first
int myints[] = {1776,7,4};
third.assign (myints,myints+3); // assigning from array.
std::cout << "Size of first: " << int (first.size()) << '\n';
std::cout << "Size of second: " << int (second.size()) << '\n';
std::cout << "Size of third: " << int (third.size()) << '\n';
return 0;
}
http://www.cplusplus.com/reference/vector/vector/assign/
相關文章
- vector——C++C++
- c++ vectorC++
- C++ STL -- vectorC++
- C++ Vector fundamentalC++
- C++(std::vector)C++
- C++的vector容器C++
- C++簡單vectorC++
- c++ vector容器、字串C++字串
- C++之vector容器C++
- C++ 容器vector的使用C++
- c++ std::vector 切記C++
- C++【vector】用法和例子C++
- C++中vector<int>& numsC++
- C++ Vector資料插入C++
- c++ vector用法詳解C++
- c/c++ 標準庫 vectorC++
- C++ ——vector陣列筆記C++陣列筆記
- C++ vector 列表初始化C++
- C++ vector<std::tuple<XXX, XXX, XXX>>C++
- C++ vector 的一些操作C++
- 自己動手寫Vector【Cherno C++教程】C++
- C++ vector容器的swap方法(容器互換)C++
- C++筆記— 排序函式sort() 和vector容器C++筆記排序函式
- c++ vector容器——檢測更改容量和大小 示例C++
- C++ 學習筆記(1):STL、Vector 與 SetC++筆記
- c++ 中vector 常見用法(給初學者)C++
- C++ folly庫解讀(二) small_vector —— 小資料集下的std::vector替代方案C++
- [20210218]Select vs Assign – How To Assign PLSQL Variables.txtSQL
- C++ vector 釋放記憶體的兩種方法C++記憶體
- c++ 從vector擴容看noexcept應用場景C++
- location.assign()
- object.assignObject
- C++ vector 元素數量變化不能使用範圍 forC++
- Object.assign()方法Object
- vector
- Object.assign 模組Object
- 【Lintcode】1230. Assign CookiesCookie
- Object.assign()的痛點Object