stl list how do swap iterators?

Intrebari despre limbajul C++, standardul C++, STL, OOP in C++ sau alte subiecte nelegate de VisualC++

stl list how do swap iterators?

Mesajde rolandbaker » 13 Apr 2017, 08:19

stl list how do swap iterators?

list <string>::iterator it = myList.begin();
string firstLine;
string secondLine;
string tempbucket;
list <string>::iterator it2;

cout << "Enter first line to swap (Line 1 is 1, Line 5 is 5): ";
cin >> firstLine;
cout << "Enter second line to swap (Line 1 is 1, Line 5 is 5): ";
cin >> secondLine;

advance(it,firstLine);
advance(it2,secondLine);
myList.swap(*it,*it2);


Thanks,
I didn't find the right solution from the internet.

References:
- http://www.cplusplus.com/forum/beginner/213111/


- 3D International Trade Video Examples
rolandbaker
Junior
Junior
 
Mesaje: 29
Membru din: 25 Feb 2017, 15:38
Judet: Vaslui

Înapoi la Limbajul C++

Cine este conectat

Utilizatorii ce navighează pe acest forum: Niciun utilizator înregistrat şi 1 vizitator

cron