set2.cpp

We use cookies. Read the Privacy and Cookie Policy

set2.cpp

#include ‹iostream.h›

#include ‹stl.h›

int main() {

 set‹int, less‹int› › s;

 pair‹set‹int, less‹int› ›::const_iterator, bool› p;

 p = s.insert(42);

 if (p.second) cout ‹‹ "Inserted new element " ‹‹ *(p.first) ‹‹ endl;

 else cout ‹‹ "Existing element = " ‹‹ *(p.first) ‹‹ endl;

 p = s.insert(42);

 if (p.second) cout ‹‹ "Inserted new element " ‹‹ *(p.first) ‹‹ endl;

 else cout ‹‹ "Existing element = " ‹‹ *(p.first) ‹‹ endl;

 return 0;

}