The Standard Template Library Common Classes
Set
Example 1:
Create a set that holds string values. Print the size. Using a for each loop print all the elements to the console screen.
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main()
{
set<string> strList = { "john", "Paul", "Jesse", "Patty", "John", "john"};
cout << "Size of the list is " << strList.size() << endl;
for (auto&&
s : strList)
{
cout << s << endl;
}
system("pause");
return 0;
}
Comments
Post a Comment