c++ stl stack
Prototype:
原型:
stack
st; //declaration
st.push(T item);
Parameter:
参数:
T item; //T is the data type
Return type: void
返回类型: void
Header file to be included:
包含的头文件:
#include <iostream>
#include <stack>
OR
#include <bits/stdc++.h>
Usage:
用法:
The function pushes elements to the stack.
该函数将元素压入堆栈。
Time complexity: O(1)
时间复杂度:O(1)
Example:
例:
For a stack of integer,
stack<int> st;
st.push(4);
st.push(5);
stack content:
5
C++ implementation:
Output
...use of push function...
stack elements are:
5
4
翻译自: https://www.includehelp.com/stl/stack-push-function-in-cpp-stl.aspx
c++ stl stack