Original source: http://blog.csdn.net/chenzhenyu123456/article/details/44519943
Stack:
(a) header file #include <stack>
(ii) Definition of stack stack<int>s;
(iii) Use
1:s.empty () stack is null returns TRUE, otherwise returns false;
2:s.size () returns the number of elements in the stack
3:s.pop () removes the top element of the stack without returning its value
4:s.top () returns the element at the top of the stack without deleting the element
5:s.push () pushes a new element at the top of the stack
Queue:
(a) header file #include <queue>
(ii) Definition of queue<int>q;
(iii) Use
1:q.empty () returns True if the queue is empty , otherwise false;
2:q.size () returns the number of elements in the queue
3:q.pop () deletes the first element of the queue but does not return its value
4:q.front () Returns the value of the first element of the team, but does not delete the element
5:q.push () Press the new element at the end of the team
6:q.back () Returns the value of the tail element of the queue, but does not delete the element
Go: Stack and queue trivia "STL usage"