Aracılığıyla paylaş


vector::reserve

Depolama alanı ayrılıyor gerekirse bir vektör nesnesi için minimum uzunluğu ayırır.

void reserve(
   size_type _Count
);

Parametreler

  • _Count
    Depolama için vektör tahsis edilecek minimum uzunluğu.

Örnek

// 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;
}
  

Gereksinimler

Başlık: <vector>

Namespace: std

Ayrıca bkz.

Başvuru

vector Class

Standart Şablon Kütüphanesi