How to insert something in a list using it's iterator? for example I have a list of objects myobj where myobj contains another list<int>.
class myobj {
list<int> l;
};
list <myobj> x;
Suppose I want call the insert() function for the list in the nth element of x, I'll do something like
list<int>::iterator itr = x.begin();
itr+=n;
itr->insert(n); //It gives a compilation error.
I tried to learn insert_iterator but most of the examples I got were used with copy() function but here I want to call the insert() function of the list inside myobj.
Aucun commentaire:
Enregistrer un commentaire