stack::push
元素添加到堆栈顶部的。
void push(
const Type& _Val
);
参数
- _Val
元素添加到堆栈顶部的。
备注
堆栈的顶部是最近添加的元素占用的位置也是最后一个元素在容器的末尾。
示例
// stack_push.cpp
// compile with: /EHsc
#include <stack>
#include <iostream>
int main( )
{
using namespace std;
stack <int> s1;
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;
}
要求
页眉: <堆栈>
命名空间: std