stack::pop
從堆疊頂端移除項目。
void pop( );
備註
堆疊必須是空套用成員函式。 堆疊頂端的是最近加入的項目所佔用之定位和是最後一個項目至容器結尾。
範例
// stack_pop.cpp
// compile with: /EHsc
#include <stack>
#include <iostream>
int main( )
{
using namespace std;
stack <int> s1, s2;
s1.push( 10 );
s1.push( 20 );
s1.push( 30 );
stack <int>::size_type i;
i = s1.size( );
cout << "The stack length is " << i << "." << endl;
i = s1.top( );
cout << "The element at the top of the stack is "
<< i << "." << endl;
s1.pop( );
i = s1.size( );
cout << "After a pop, the stack length is "
<< i << "." << endl;
i = s1.top( );
cout << "After a pop, the element at the top of the stack is "
<< i << "." << endl;
}
需求
標題: <stack>
命名空間: std