forked from JiauZhang/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvector.cpp
More file actions
34 lines (24 loc) · 768 Bytes
/
Copy pathvector.cpp
File metadata and controls
34 lines (24 loc) · 768 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <vector>
using namespace std;
/*
vector<T>::reserve is used to alloc memory
vector<T>::resize is reset the occpied memory pointer
*/
int main(int argc, char** argv) {
vector<int> test;
cout << "test size: " << test.size() << endl;
cout << "test cap: " << test.capacity() << endl;
test.reserve(10);
cout << "test size: " << test.size() << endl;
cout << "test cap: " << test.capacity() << endl;
test.push_back(10);
test.push_back(11);
cout << "test size: " << test.size() << endl;
cout << "test cap: " << test.capacity() << endl;
test.resize(6);
test.push_back(66);
cout << "test size: " << test.size() << endl;
cout << "test cap: " << test.capacity() << endl;
return 0;
}