set::clear

清除任何一組裝置上的元件。

void clear( );

範例

// set_clear.cpp
// compile with: /EHsc
#include <set>
#include <iostream>

int main( )
{
   using namespace std;   
   set <int> s1;
   
   s1.insert( 1 );
   s1.insert( 2 );

   cout << "The size of the set is initially " << s1.size( )
        << "." << endl;

   s1.clear( );
   cout << "The size of the set after clearing is " 
        << s1.size( ) << "." << endl;
}
  
  

需求

標題: <set>

命名空間: std

請參閱

參考

set Class

set::empty 和 set::clear

標準樣板程式庫