std::stack #include int main() { std::stack s; for (int i = 0; i < 10; i++) s.push(i); while ( ! s.empty()) { std::cout << s.top() << stl::endl; s.pop(); } } Also has s.size()