September 2017
Beginner to intermediate
384 pages
8h 4m
English
The following table shows commonly used stack APIs:
|
API |
Description |
|
top() |
This returns the top-most value in the stack, that is, the value that was added last |
|
push<data_type>( value ) |
This will push the value provided to the top of the stack |
|
pop() |
This will remove the top-most value from the stack |
|
size() |
This returns the number of values present in the stack |
|
empty() |
This returns true if the stack is empty; otherwise it returns false |
It's time to get our hands dirty; let's write a simple program to use a stack:
#include <iostream>#include <stack>#include <iterator>#include <algorithm>using namespace std;int main ( ) { stack<string> spoken_languages; spoken_languages.push ...