// copyit.cpp -- copy() and iterators #include #include #include int main() { using namespace std; int casts[10] = {6, 7, 2, 9 ,4 , 11, 8, 7, 10, 5}; vector dice(10); // copy from array to vector copy(casts, casts + 10, dice.begin()); cout << "Let the dice be cast!\n"; // create an ostream iterator ostream_iterator out_iter(cout, " "); // copy from vector to output copy(dice.begin(), dice.end(), out_iter); cout << endl; cout <<"Implicit use of reverse iterator.\n"; copy(dice.rbegin(), dice.rend(), out_iter); cout << endl; cout <<"Explicit use of reverse iterator.\n"; // vector::reverse_iterator ri; // use if auto doesn't work for (auto ri = dice.rbegin(); ri != dice.rend(); ++ri) cout << *ri << ' '; cout << endl; // cin.get(); return 0; }