i番目のの要素への参照を返す
reference operator[](size_type i); const_reference operator[](size_type i) const; |
#include <iostream> #include <deque> using namespace std; int main() { deque<char> ob; int i; ob.resize(10); for(i=0; i<10; i++) ob[i] = 'a' + i; for(i=0; i<10; i++) cout << ob[i] << " "; return 0; } |
実行結果
b c d e f g h i j |
サイズを超える要素を指定することはできない。