D
Dave
Hello all,
1. Are there any problems with the code below?
2. Is there a better way to accomplish what this code does?
Thanks,
Dave
#include <iostream>
#include <set>
using namespace std;
int main()
{
set<int> s;
for (int i = 0; i != 100; ++i)
s.insert(i);
// Erase all elements but the first.
s.erase(++s.begin(), s.end());
cout << s.size() << endl;
cout << *s.begin() << endl;
}
1. Are there any problems with the code below?
2. Is there a better way to accomplish what this code does?
Thanks,
Dave
#include <iostream>
#include <set>
using namespace std;
int main()
{
set<int> s;
for (int i = 0; i != 100; ++i)
s.insert(i);
// Erase all elements but the first.
s.erase(++s.begin(), s.end());
cout << s.size() << endl;
cout << *s.begin() << endl;
}