CHAPTER5-24.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
- //文件名:CHAPTER5-24.cpp
- #include <iostream>
- #include <set>
- int main()
- {
- // type of the collection
- typedef std::set<int> IntSet;
- IntSet coll; // set 容器 for int values
- /* insert elements from 1 to 6 in arbitrary order-value1 gets inserted twice*/
- coll.insert(3);
- coll.insert(1);
- coll.insert(5);
- coll.insert(4);
- coll.insert(1);
- coll.insert(6);
- coll.insert(2);
- /* print all elements iterate over all elements*/
- IntSet::const_iterator pos;
- for (pos = coll.begin(); pos != coll.end(); ++pos) {std::cout << *pos << ' ';}
- std::cout << std::endl;
- }