STL Samples : <stack>
スタック
#include <iostream> #include <stack> using namespace std; void std_stack() { cout << "stack" << endl; stack<int> stk; cout << "push... "; for ( int i = 0; i < 5; i++ ) { stk.push(i); cout << i << ' '; } cout << endl << "pop... "; while ( !stk.empty() ) { cout << stk.top() << ' '; stk.pop(); } cout << endl; }