Similar Problems

Similar Problems not available

stack::pop() function in C++ STL

In C++, the standard library gives us the facility to use the Stacks as a type of container adaptors with LIFO type of working. The stack::pop() is a C++ Standard Library function which is used to remove an element from the top of the stack. After removing the element to the stack container the size decreased by 1.

Syntax

Stack_Name.pop( );

Parameter: The stack::pop() function does not accepts any parameter.

Return value: The stack::pop() function does not returns any value.

Example of stack::pop() Function

#include <iostream>

#include <stack>

using  namespace std;

int  main()

{

stack<int> STK;

STK.push(10);

STK.push(20);

STK.push(30);

while  (!STK.empty())

{

cout << STK.top()  <<  ' ';

STK.pop();

}

}

Output

30 20 10