Ho una semplice lista:
E desidero inserire un mio oggetto in una posizione specifica, per esempio in posizione 2 (la lista ha più di due elementi), come posso fare?codice:list<obj> my_list;
Ho una semplice lista:
E desidero inserire un mio oggetto in una posizione specifica, per esempio in posizione 2 (la lista ha più di due elementi), come posso fare?codice:list<obj> my_list;
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.
http://www.cplusplus.com/reference/stl/list/insert/
Per esempio:
L'elemento è inserito prima dell'iteratore it.codice:auto it = my_list.begin(); advance(it, 3); my_list.insert(it, other_obj);
This code and information is provided "as is" without warranty of any kind, either expressed
or implied, including but not limited to the implied warranties of merchantability and/or
fitness for a particular purpose.
Grazie, non conoscevo il metodo advance.
Fracty - The Fractal Generator
If you cannot choose a concise name that expresses what the method does, it is possible that your method is attempting to perform too many diverse tasks.