C + + STL stack

Source: Internet
Author: User

A stack is a data structure for FIFO (first in the last Out,filo), and the use of stacks requires the introduction of header file #include<stack>. The stack does not provide traversal functionality, nor does it provide an iterator, which has only one exit, as shown in the form.

constructor function
Function prototypes Function
Stack<t> StkT Stack is implemented as a template class, and the default constructor for stack objects
Stack (const stack &stk) Copy constructor

Assign value
Function prototypes Function
stack& operator= (const stack &stk) Overloaded equals operator

Basic operations
member functions Function
Push (Elem) Add a elem element to the top of the stack
Pop () Remove the first element from the top of the stack
Elem Top () Returns the top element of the current stack
BOOL Empty () Evaluates if the stack is empty, the stack null returns TRUE, otherwise returns false
int size () Returns the number of elements in the stack

C + + STL stack

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.