共用方式為


multimap::clear

清除多重對應的所有項目。

void clear( );

範例

當編譯這個範例會使用 /Wp64 旗標或在 64 位元平台時,編譯器警告 C4267 會產生。 如需這項警告的詳細資訊,請參閱 編譯器警告 (層級 3) C4267

// multimap_clear.cpp
// compile with: /EHsc
#include <map>
#include <iostream>

int main( )
{
   using namespace std;
   multimap<int, int> m1;
   multimap<int, int>::size_type i;
   typedef pair<int, int> Int_Pair;

   m1.insert(Int_Pair(1, 1));
   m1.insert(Int_Pair(2, 4));

   i = m1.size();
   cout << "The size of the multimap is initially "
        << i << "." << endl;

   m1.clear();
   i = m1.size();
   cout << "The size of the multimap after clearing is "
        << i << "." << endl;
}
  

需求

標頭:<map>

命名空間: std

請參閱

參考

multimap 類別

標準樣板程式庫