Set in Visual Studio 2005!
-
Hello, How to use the STL set in C++ in Visual Studio 2005? thanks and regards,
Software Developer Sanjay Khapre
#include <set> #include <iostream> int main(int, char**) { // Create an integer set and initialise it std::set<int> a_set; a_set.insert(10); a_set.insert(1); a_set.insert(4); a_set.insert(7); // This should say 8 is NOT in the set if (a_set.find(8) != a_set.end()) std::cout << "8 is in the set" << std::endl; else std::cout << "8 is NOT in the set" << std::endl; // This should say 7 is in the set if (a_set.find(7) != a_set.end()) std::cout << "7 is in the set" << std::endl; else std::cout << "7 is NOT in the set" << std::endl; // Remove 7 from the set a_set.erase(7); // This should say 7 is NOT in the set if (a_set.find(7) != a_set.end()) std::cout << "7 is in the set" << std::endl; else std::cout << "7 is NOT in the set" << std::endl; }
HTH!!!