Code like:
list<const char *> lst_city = {"NewYork", "Tokoyo", "ShenZhen"};
vector<string> vs_city;
vs_city.assign(lst_city.cbegin(), --lst_city.cend());
This is right.But if i do like this ,will be wrong:
vs_city.assign(lst_city.cbegin(), lst_city.cend() - 1);
What's the difference -- and - 1,i am not very clear. If it was a vector, it will be good too.So it was just because the bilateral of the list?
Aucun commentaire:
Enregistrer un commentaire