back

提供:cppreference.com
移動: 案内, 検索

Syntax:

    #include <vector>
    T& back();
    const T& back() const;

back()関数はベクタの最後の要素への参照を返却する。 例:

   vector<int> v;
   for( int i = 0; i < 5; i++ ) {
     v.push_back(i);
   }
   cout << "The first element is " << v.front()
        << " and the last element is " << v.back() << endl;

このコードは次の出力をする:

   The first element is 0 and the last element is 4

back()関数は 定数時間で動作する。

Related Topics: front, pop_back

個人用ツール
名前空間
変種
操作
案内
ツールボックス
他の言語