Hey all,
I want to save a map in a vector that contains maps :
vector<map<string,unsigned int>>
code:
vector<map<string,unsigned int>> map_vec;
vector<map<string,unsigned int>>::iterator mapind; // iterator for vector
map<string,unsigned int> mapst;
mapind=map_vec.begin();
.
.
.
*mapind=mapst; // why that is wrong ?? how to correct it ??
Thank you
If the vector is empty you may not assign to it elements such a way. Use push_back method instead.
Last edited on
Iterators are just temporary objects that hold a piece of their associated STL container. In this case you want to do:
map_vec.push_back(mapst);
instead of your *mapind=mapst;
If you need further help with this just ask! I've been making maps of maps of maps of vectors recently so I'm pretty much wired on the subject
Regards,
Anthony