共用方式為


list::pop_back

刪除項目清單結尾的。

void pop_back( );

備註

最後一個元素不可以是 null。 pop_back 絕不會擲回例外狀況。

範例

// list_pop_back.cpp
// compile with: /EHsc
#include <list>
#include <iostream>

int main( ) 
{
   using namespace std;
   list <int> c1;
   
   c1.push_back( 1 );
   c1.push_back( 2 );
   cout << "The first element is: " << c1.front( ) << endl;
   cout << "The last element is: " << c1.back( ) << endl;

   c1.pop_back( );
   cout << "After deleting the element at the end of the list, "
           "the last element is: " << c1.back( ) << endl;
}
  

需求

標題: <list>

命名空間: std

請參閱

參考

list Class

標準樣板程式庫