C++ stack and queue adapters
std::stack exposes a last-in, first-out interface, while std::queue exposes a first-in, first-out interface. They adapt underlying containers rather than exposing arbitrary indexing.
C++
#include <iostream>
#include <stack>
#include <queue>
int main() {
std::stack<int> stack;
std::queue<int> queue;
for (int value : {1, 2, 3}) { stack.push(value); queue.push(value); }
std::cout << stack.top() << ' ' << queue.front() << '\n';
stack.pop();
queue.pop();
std::cout << stack.top() << ' ' << queue.front() << '\n';
}