#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
vector<char> vectorObject(10);
vector<char> vectorObject2(10);
int i;
for(i = 0; i < 10; i++)
vectorObject[ i ] = 'A' + i;
for(i = 0; i < 10; i++)
vectorObject2[ i ] = '0' + i;
cout << "Original contents of vectorObject:";
for(i = 0; i < 10; i++)
cout << vectorObject[ i ] << " ";
cout << endl;
cout << "Original contents of vectorObject2:";
for(i = 0; i < 10; i++)
cout << vectorObject2[ i ] << " ";
cout << endl;
// swap ranges in vectorObject and vectorObject2
swap_ranges(vectorObject.begin() + 2, vectorObject.end() - 3, vectorObject2.begin() + 4);
cout << "Contents of vectorObject after swap:";
for(i = 0; i < 10; i++)
cout << vectorObject[ i ] << " ";
cout << endl;
cout << "Contents of vectorObject2 after swap:";
for(i = 0; i < 10; i++)
cout << vectorObject2[ i ] << " ";
cout << endl;
return 0;
}
|