STL スタック
STL std::stack
#include <stack>
#include <iostream>
#include <vector>
//後入れ先だし コンストラクタにより、空の状態で初期化される。
void test1()
{
std::stack<int> st;
st.push(10);
st.push(20);
std::cout<<st.top()<<std::endl;
st.pop();
}
void test2()
{
std::stack<int, std::vector<int> > st;
st.push(10);
st.push(20);
st.pop();
std::cout<<st.top()<<std::endl;
std::cout<<st.size()<<std::endl;
if(st.empty())
{
std::cout<<"スタックは空です"<<std::endl;
}
else
{
std::cout<<"スタックは空ではありません"<<std::endl;
}
}
int main()
{
test2();
return 0;
}