Besides the fact that you don't have to dynamically allocate each set, laserlight's solution still works even if the number of sets isn't known until runtime. As long as you know how many sets there will be before execution reaches the part of code that initializes the vector, you can construct it or resize it to hold the correct amount of empty sets.
Some examples of options:
Code:
std::vector<std::set<int> > theVector;
while (haveMoreSets)
{
std::set<int> theSet;
// fill theSet with data
theVector.push_back(theSet);
// Set haveMoreSets to true or false
}
Code:
std::vector<std::set<int> > theVector;
while (haveMoreSets)
{
theVector.push_back(std::set<int>());
std::set<int>& theSet = theVector.back(); // notice the reference
// fill theSet with data
// Set haveMoreSets to true or false
}
Code:
std::cin >> numberOfSets;
std::vector<std::set<int> > theVector(numberOfSets);
for (size_t i = 0; i < numberOfSets; ++i)
{
// fill theVector[i] with data
}