template <class BidirectionalIterator1, BidirectionalIterator2> BidirectionalIterator2 move_backward( BidirectionalIterator1 xFirst, BidirectionalIterator1 xLast, BidirectionalIterator2 xDest );
#include <algorithm>
#include <iostream>
#include <vector>
#include <algorithm>
int main()
{
using namespace std;
// Create a vector instance
vector<char> qV;
qV.push_back('X');
qV.push_back('o');
qV.push_back('a');
qV.push_back('X');
qV.push_back('.');
qV.push_back('n');
qV.push_back('e');
qV.push_back('t');
vector<char>::iterator qIter;
// Output the vector
cout << "The Vector: ";
for (qIter = qV.begin(); qIter != qV.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Move the first four entries to the end of a new vector
vector<char> qMove(10, '*');
qIter = move_backward(qV.begin(), qV.begin() + 4, qMove.end());
cout << "Moved Vector: ";
for (qIter = qMove.begin(); qIter != qMove.end(); ++qIter) {
cout << *qIter;
}
cout << endl;
// Keep the window open
cin.get();
return 0;
}
© 20072025 XoaX.net LLC. All rights reserved.