Swap content
Exchanges the content of the vector by the content of lst, which is another list object containing elements of the same type. Sizes may differ.
// swap lists
#include
#include
using namespace std;
main ()
{
list
// three ints with a value of 100
list
// five ints with a value of 200
list
first.swap(second);
cout << "first contains:";
for (it=first.begin(); it!=first.end(); it++) cout << " " << *it;
cout << "\nsecond contains:";
for (it=second.begin(); it!=second.end(); it++) cout << " " << *it;
cout << endl;
return 0;
}
Output:
first contains: 200 200 200 200 200
second contains: 100 100 100
No comments:
Post a Comment