Use indexer to add elements to a deque : deque subscript indexer « deque « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

int main()
{

  deque<int>  deque1(5);

  for (int i = 0; i < 5; ++i)
    deque1[i] = i + 5;

  deque<int>::iterator pos;

  for (pos=deque1.begin(); pos!=deque1.end(); ++pos) {
        cout << *pos << ' ';
  }

  return 0;
}
5 6 7 8 9 "








22.11.deque subscript indexer
22.11.1.Use indexer to add elements to a deque
22.11.2.Use subscript operator to modify element at location 1
22.11.3.Use subscript operator to obtain elements of values
22.11.4.Print out a deque, reference its content by index,
22.11.5.Change the values of some of deque's elements
22.11.6.Insert 'value' into every element but the first