容器set find

// set::find
#include 
#include 

int main ()
{
  std::set myset;
  std::set::iterator it;

  // set some initial values:
  for (int i=1; i<=5; i++) myset.insert(i*10);    // set: 10 20 30 40 50

  it=myset.find(20);
  myset.erase (it);
  myset.erase (myset.find(40));

  std::cout << "myset contains:";
  for (it=myset.begin(); it!=myset.end(); ++it)
    std::cout << ' ' << *it;
  std::cout << '\n';

  return 0;
}




myset contains: 10 30 50
set si;
si.clear(); //清空set
 
  

你可能感兴趣的:(C++)