#include<iostream>
#include<deque>
using namespace std;
//deque赋值操作
void printdeque(const deque<int>& a) {//加const容器只能读不能修改
for (deque<int>::const_iterator j = a.begin(); j != a.end(); j++) {
cout << *j << " ";//迭代器也要变成只读迭代器
}
cout << endl;
}
void test01() {
deque<int>d;
for (int i = 0; i < 10; i++) {
d.push_back(i);
}
printdeque(d);
//operator=赋值
deque<int>d1;
d1 = d;
printdeque(d1);
//assign
deque<int>d2;
d2.assign(d1.begin(), d1.end());
printdeque(d2);
//assign
deque<int>d3;
d3.assign(10, 100);
printdeque(d3);
}
int main() {
test01();
system("pause");
return 0;
}
deque容器赋值操作
最新推荐文章于 2024-09-03 11:25:36 发布