vector::reserve
保留儲存區的最小長度向量的物件,如果有需要,配置空間。
void reserve(
size_type _Count
);
參數
- _Count
做為向量會配置儲存區的最小長度。
範例
// vector_reserve.cpp
// compile with: /EHsc
#include <vector>
#include <iostream>
int main( )
{
using namespace std;
vector <int> v1;
//vector <int>::iterator Iter;
v1.push_back( 1 );
cout << "Current capacity of v1 = "
<< v1.capacity( ) << endl;
v1.reserve( 20 );
cout << "Current capacity of v1 = "
<< v1.capacity( ) << endl;
}
需求
標題: <vector>
命名空間: std