Change
This commit is contained in:
31
LinearList/STL-Vector/define.cpp
Normal file
31
LinearList/STL-Vector/define.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
using namespace std;
|
||||
int main(){
|
||||
vector<int> a;
|
||||
vector<int> b(3,100);//b = {100, 100, 100}
|
||||
vector<int> c(b.begin(),b.end());
|
||||
vector<int> d(c);
|
||||
|
||||
for(/*vector<int>::iterator*/ auto ti = b.begin(); ti != b.end(); ti++){
|
||||
cout << *ti << " ";
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
b.push_back(300);
|
||||
b.push_back(500);
|
||||
|
||||
cout << b.size() << " " << b.capacity() << endl;
|
||||
b.resize(10);
|
||||
b.reserve(100);
|
||||
cout << b.size() << " " << b.capacity() << endl;
|
||||
|
||||
auto ti = b.begin() + 3;
|
||||
b.insert(ti, 20);
|
||||
for(int i = 0; i < b.size(); i++){
|
||||
cout << b.at(i) << " ";
|
||||
}
|
||||
cout << endl;
|
||||
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user