Free for PREMIUM members
We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
void OutputInt(int n)
std::cout << n << std::endl;
// Create typedef to make code cleaner
typedef std::set<int> IntSet;
// Create instance of int set
// Populate int set
for(int i = 0 ; i < 100 ; ++i)
// Traverse using for loop
std::cout << "Traverse set using normal C++ for loop and output contents" << std::endl;
for(IntSet::const_iterator itr = intSet.begin() ; itr != intSet.end() ; ++ itr)
// You need to dereference itr to get reference to type it represents
// Iterators have pointer semantics
// Traverse set using STL for_each
std::cout << "Traverse set using STL for_each and output contents" << std::endl;
std::for_each(intSet.begin(), intSet.end(), OutputInt);
Open in new window
Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.