Translations of this page?:

back

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

 
• • • SitemapRecent changesRSScc