C++ copy和copy_backward用法實例
#include
#include
#include
using namespace std;
int main()
{
// 數組大小為7
int myInts[] = {10,20,30,40,50,60,70};
// 容器大小為8,裡面有8個7
vector myVector(8,7);
// 1.將數組中的7個數復制到容器的第一個位置,將覆蓋容器的前7個數
copy(myInts,myInts + 7,myVector.begin());
for(vector::iterator it = myVector.begin();it != myVector.end();it++)
cout<<" "<<*it;
cout<::iterator it = myVector.begin();it != myVector.end();it++)
cout<<" "<<*it;
cout<::iterator it = myVector.begin();it != myVector.end();it++)
cout<<" "<<*it;
cout<