S
Steve Edwards
Hi,
1)
I'm making a container for string pointers...
set<string*> strSet;
strSet.insert(...); // insert some strings
....
....
But when I come to iterate over them, I'm getting an error that there is
no operator= for iter:
set<string>::iterator iter;
for(iter = *strSet.begin(); iter != strSet.end(); iter++)
This is exactly what I did when I was learning about maps, and it worked
fine. Have I misunderstood, or should iterators work the same with all
containers?
2)
I could just as easily use a vector for these strings, and remove the
duplicates manually. However, when I tried this, nothing got removed,
even though I had no compiler errors:
vector<string> strVec;
strVec.push_back("test");
strVec.push_back("test");
strVec.push_back("test");
strVec[2].erase();
My text book states that vector is not ideal for random access removal,
but not that it is impossible. have I got this wrong?
Thanks
Steve
1)
I'm making a container for string pointers...
set<string*> strSet;
strSet.insert(...); // insert some strings
....
....
But when I come to iterate over them, I'm getting an error that there is
no operator= for iter:
set<string>::iterator iter;
for(iter = *strSet.begin(); iter != strSet.end(); iter++)
This is exactly what I did when I was learning about maps, and it worked
fine. Have I misunderstood, or should iterators work the same with all
containers?
2)
I could just as easily use a vector for these strings, and remove the
duplicates manually. However, when I tried this, nothing got removed,
even though I had no compiler errors:
vector<string> strVec;
strVec.push_back("test");
strVec.push_back("test");
strVec.push_back("test");
strVec[2].erase();
My text book states that vector is not ideal for random access removal,
but not that it is impossible. have I got this wrong?
Thanks
Steve