C ++ stack STL containers simple to use

#include <iostream>
#include <stack>
#include <string>
using namespace std;
void test1() {
	stack<int> s;
	s.push(10);
	s.push(20);
	s.push(30);
	while (s.size())	{
		cout << "stack top is" << s.top() << endl; // 栈顶
		s.pop();  // 出栈
	}
}
int main()
{
	test1();
	return 0;
}

container stack is a stack structure, advanced after, does not support traversal, no iterator

Published 105 original articles · won praise 6 · views 10000 +

Guess you like

Origin blog.csdn.net/weixin_43903378/article/details/104079417