![]() |
In C++, Stacks are a type of container adaptor with LIFO(Last In First Out) type of working, where a new element is added at one end (top) and an element is removed from that end only. In this article, we will learn how to declare a stack in C++. Declaring a Stack in C++ STLThe C++ STL provides a container std::stack that implements stack data structure. To declare a stack, we can use the following syntax Syntax to Declare a Stackstack<dataType> stackName;
Here,
C++ Program to Declare A StackC++
Output
Top element of the stack is: 30 The stack is not empty. Size of the stack: 2 Time Complexity: O(N) |
Reffered: https://www.geeksforgeeks.org
C++ |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |